【发布时间】:2018-11-15 11:26:23
【问题描述】:
我创建了一个项目,基于:https://github.com/framework7io/framework7-template-vue-simple...
在深入导航多个子视图后,我需要能够导航回主视图/主视图...当我回击后堆栈中的倒数第二个项目和建议时,它肯定是在尝试导航到 /我提出的问题 (https://github.com/framework7io/framework7-template-vue-simple/issues/7) 是引用路由 / 的主页/主视图组件。
我的 Vue / Framework7 应用程序初始化为:
var vm = new Vue({
el: '#app',
data: function () {
return {
// Framework7 parameters here
f7params: {
root: '#app', // App root element
id: 'io.framework7.testapp', // App bundle ID
name: 'Framework7', // App name
theme: 'md', // Automatic theme detection,
stackPages: true,
domCache: true,
// App routes,
routes: [
{
path: '/submenu/category/:categoryId/',
component: 'ym-submenu',
}, {
path: '/submenu/menuitem/:menuitemId/',
component: 'ym-submenu',
}, {
path: '/',
component: 'app'
}]
},
rootAreas: [],
categories: [],
news: [],
searchResults: [],
submenuContent: []
};
},
created: function () {
console.log('Created Main App');
documentReady();
this.$on('rootmapsUpdated', function (arg) {
this.rootAreas = arg;
});
this.$on('categoriesUpdated', function (arg) {
this.categories = arg;
});
this.$on('newsUpdated', function (arg) {
this.news = arg;
});
this.$on('searchResultsUpdated', function (arg) {
this.searchResults = arg;
});
this.$on('submenuContentUpdated', function (arg) {
this.submenuContent = arg;
});
}
});
我不知道如何实现这一点... 我尝试创建一个指向#app 的组件
Vue.component('app', {
template: '#app'
});
并使用以下方法路由到它:
routes: [{
path: '/',
component: 'app'
},
...
我还尝试将this 作为组件并将new Vue() 的结果分配给全局变量并将其作为组件。我还尝试使用url: 而不是component: 和类似templateUrl: 路由到index.html...
我尝试过的任何方法都没有奏效...任何提示/想法表示赞赏
【问题讨论】: