路径的路由配置“组件”:/不能是字符串ID

时间:2019-01-23 09:51:04

标签: vue.js vue-router

我正在使用vue-router在我的网站中构建路线,我试图以coreui does it的相同方式设置路线文件。我目前收到错误“ [vue-router]路由配置component" for path: / cannot be a string id. Use an actual component instead

./ src / router / index.js

import Vue from 'vue';
import Router from 'vue-router';

// Containers
const DefaultContainer = '../containers/DefaultContainer'; 

// Componenets
// const Navbar = '../components/Navbar';

// Views
const Home = '../views/Home';
const PageNotFound = '../views/404';

// Routes
Vue.use(Router)

export default new Router ({
mode: 'hash',
routes: [
    {
        path: '/',
        redirect: '/home',
        name: 'Home | Portfolio | Tom Dickson',
        component: DefaultContainer,
        children: [
            {
                path: 'home',
                name: 'Home | Portfolio | Tom Dickson',
                component: Home
            }
        ]
    },
    {
        path: '*',
        component: PageNotFound
    }
]
})

1 个答案:

答案 0 :(得分:0)

嗯...回到它身边,就在我的面前:

已更改

// Containers const DefaultContainer = '../containers/DefaultContainer';

收件人

// Containers const DefaultContainer = () => import('../containers/DefaultContainer');

然后更新了我的其余观点...