Created
December 21, 2020 08:28
-
-
Save chillbits-legacy/ac705468547705ba17f19a2e0f312cf0 to your computer and use it in GitHub Desktop.
Mount Vue app on multiple DOMs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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