如何在通過ajax獲取路由之後動態創建路由數組?vue-router 2,如何通過ajax獲取路由?
有沒有辦法在路由器初始化後向路由器添加/推送新路由?
這不起作用:
new Vue({
el: '#app',
template: '<App/>',
data: {
content: []
},
created: function() {
this.$http.get('dummyjsondatafornow').then((response) => {
// this doesn't work when creating the VueRouter() outside the Vue instance, as in the docs.
// this.$router.options.routes.push({ path: '/about', component: About })
let routes = [
{ path: '/about', component: About }
]
// this doesn't work either
this.router = new VueRouter({
routes: routes
})
})
},
// router: router,
components: { App }
})
我可以理解爲創建服務器端動態路由,而是動態的路線SPA?重點在哪裏? –
那麼,SPA的內容(包括頁面/路線)將在獨立系統(CMS)中進行管理。我還能怎麼解決這個問題? – Emin