mirror of
https://github.com/tenrok/vue-meta.git
synced 2026-05-17 12:39:38 +03:00
fc71e1f1c4
* refactor(examples): run ssr example from server * chore: switch to babel for build buble complains too much * feat: enable loaded callbacks feat: add skip option * examples: add async-callback browser example * examples: fix server * examples(ssr): add reactive script with callback * fix: also skip on ssr * chore: remove unused var * feat: only add mutationobserver if DOM is still loading feat: disconnect mutation observer once DOM has loaded * examples: pass vmid to loadCallback instead of el * feat: also support load callbacks for link/style tags * test: add unit tests for load * test: add load e2e test * chore: fix lint * chore: remove unused files * test: fix e2e load callback test * test: fix attempt * examples: ie9 compatiblity destructuring doesnt work in ie9 * fix: add onload attribute on ssr dont rely on mutationobserver * chore: lint ci conf * refactor: remove loadCallbackAttribute config option test: fix coverage for load * test: improve coverage * fix: only use console when it exists (for ie9) * chore: fix coverage
83 lines
1.7 KiB
JavaScript
83 lines
1.7 KiB
JavaScript
import Vue from 'vue'
|
|
import VueMeta from 'vue-meta'
|
|
|
|
Vue.use(VueMeta)
|
|
|
|
// index.html contains a manual SSR render
|
|
|
|
const app1 = new Vue({
|
|
metaInfo () {
|
|
return {
|
|
title: 'App 1 title',
|
|
bodyAttrs: {
|
|
class: 'app-1'
|
|
},
|
|
meta: [
|
|
{ name: 'description', content: 'Hello from app 1', vmid: 'test' },
|
|
{ name: 'og:description', content: this.ogContent }
|
|
],
|
|
script: [
|
|
{ innerHTML: 'var appId=1.1', body: true },
|
|
{ innerHTML: 'var appId=1.2', vmid: 'app-id-body' }
|
|
]
|
|
}
|
|
},
|
|
data () {
|
|
return {
|
|
ogContent: 'Hello from ssr app'
|
|
}
|
|
},
|
|
template: `
|
|
<div id="app1"><h1>App 1</h1></div>
|
|
`
|
|
})
|
|
|
|
const app2 = new Vue({
|
|
metaInfo: () => ({
|
|
title: 'App 2 title',
|
|
bodyAttrs: {
|
|
class: 'app-2'
|
|
},
|
|
meta: [
|
|
{ name: 'description', content: 'Hello from app 2', vmid: 'test' },
|
|
{ name: 'og:description', content: 'Hello from app 2' }
|
|
],
|
|
script: [
|
|
{ innerHTML: 'var appId=2.1', body: true },
|
|
{ innerHTML: 'var appId=2.2', vmid: 'app-id-body', body: true }
|
|
]
|
|
}),
|
|
template: `
|
|
<div id="app2"><h1>App 2</h1></div>
|
|
`
|
|
}).$mount('#app2')
|
|
|
|
app1.$mount('#app1')
|
|
|
|
const app3 = new Vue({
|
|
template: `
|
|
<div id="app3"><h1>App 3 (empty metaInfo)</h1></div>
|
|
`
|
|
}).$mount('#app3')
|
|
|
|
setTimeout(() => {
|
|
console.log('trigger app 1')
|
|
app1.$data.ogContent = 'Hello from app 1'
|
|
}, 2500)
|
|
|
|
setTimeout(() => {
|
|
console.log('trigger app 2')
|
|
app2.$meta().refresh()
|
|
}, 5000)
|
|
|
|
setTimeout(() => {
|
|
console.log('trigger app 3')
|
|
app3.$meta().refresh()
|
|
}, 7500)
|
|
|
|
setTimeout(() => {
|
|
console.log('trigger app 4')
|
|
const App = Vue.extend({ template: `<div>app 4</div>` })
|
|
new App().$mount()
|
|
}, 10000)
|