но не содержит dataсодержит, вроде и дата и шаблон есть
:class="active: isActive"
:class="{active: isActive}"
const barVM = new Vue({
el: '#bar',
data: {
isActive: false
}
})
new Vue({
el: '#toggle',
methods: {
show: function() {
barVM.isActive = true
}
}
})
import axios from 'axios';
export default {
data:function(){
return{
subs:null,
posts:null,
tags:null,
}
},
beforeRouteEnter(_, __, next) {
axios.get('/api/getindexdata').then(response => {
next(vm => {
vm.subs = response.data.subs;
vm.posts = response.data.posts;
vm.tags = response.data.tags;
})
});
}
}
const router = new Router({
mode: 'history',
base: '/dash/vue/',
routes: [{
path: '/home',
alias: '/',
name: 'home'.
component: HomePage
}, {
name: 'test',
path: '/test',
component: TestPage
}]
})
:/dash/vue/**/*
отдавать всегда index.html
// router.js
routes: [{
name: 'index',
path: '/',
meta: {
title: 'Vuetify.js'
}
}]
//Toolbar.vue
computed: {
...mapState('router', {
currentTitle: state => state.meta.title
})
}
//Toolbar.vue
data() {
return {
currentTitle: ''
}
},
watch: {
'$route': {
handler(route) {
this.currentTitle= route.meta.title
},
immediate: true
}
}
//App.vue
<template>
<div id="app">
<router-link to="/random/12323jlwe">12323jlwe</router-link>|
<router-link to="/random/cxz98c7zf8a">cxz98c7zf8a</router-link>|
<router-link to="/random/90cvuiwa-r">90cvuiwa-r</router-link>
<section class="content">
<router-view :key="$route.fullPath"></router-view>
</section>
</div>
</template>
//main.js
import Vue from "vue";
import Router from "vue-router";
import App from "./App.vue";
Vue.use(Router);
var testComponent = Vue.component("main-section", {
template: `<component :is="template"></component>`,
data() {
return {
template: Vue.compile("<div>please stand by</div>")
};
},
created() {
// axios.post...
setTimeout(() => {
this.template = Vue.compile(`<div>${this.$route.fullPath}</div>`);
}, 2000);
},
mounted() {
console.log("mounted-" + new Date().getTime());
}
});
const router = new Router({
mode: "history",
routes: [{ path: "/random/:random", component: testComponent }]
});
/* eslint-disable no-new */
new Vue({
el: "#app",
router,
render: h => h(App)
});