相关疑难解决方法(0)

将路由拆分为单独的文件

我正在开发一个很大的Vue应用程序,现在我必须将所有路线写在一页上,router/index.js而且它已经变得太长,无法喜欢甚至无法维护。该index.js页面充满了语句,例如...

import This from '../components/This'
import That from '../components/That'
import ThatOther from '../components/ThatOther'
import ThatOtherOne from '../components/ThatOtherOne'
// and so on and so on...then at the bottom
var router = new Router({                  
routes: [
    {
        path: '/this', 
        name: 'this', 
        component: This
    },
    {
        path: '/that', 
        name: 'that', 
        component: That
    },
// and so on...so many lines of similar and "repetitive" code
Run Code Online (Sandbox Code Playgroud)

由于我的应用程序可以分组为“模块”,有没有办法将路由拆分为importlike router/this.jsrouter/that.js...', then add them to the main route page,router …

vue.js vuejs2

3
推荐指数
1
解决办法
1154
查看次数

标签 统计

vue.js ×1

vuejs2 ×1