Skip to content

Instantly share code, notes, and snippets.

@chillbits-legacy
Created December 21, 2020 08:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chillbits-legacy/ac705468547705ba17f19a2e0f312cf0 to your computer and use it in GitHub Desktop.
Save chillbits-legacy/ac705468547705ba17f19a2e0f312cf0 to your computer and use it in GitHub Desktop.
Mount Vue app on multiple DOMs
import { createApp } from 'vue'
import store from './store'
import Rita from './Rita.vue'
import './index.css'
const mounts = document.querySelectorAll('.rita')
let Apps = []
;[].forEach.call(mounts, (mount, index) => {
if ('object' === typeof mount) {
Apps[index] = createApp(Rita, {
...mount.dataset,
})
Apps[index].use(store)
Apps[index].mount(mount)
} else {
console.error('Could not render Rita on the expected mount.')
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment