使用懒加载以后就报4个错,程序能运行,这是为什么?
来源:3-3 vue-router
lin5_mumu
2018-11-23 18:47:34

使用() => import('xxxxx')以后就一直会报4个错,说灭有正确定义自定义变量,但程序可以跑
3回答
同学你好,你是不是写错标签了,还是自定义了组件,就是cpan这个,若是自定义的组件的话,需要引用下哦。

祝学习愉快!
lin5_mumu
提问者
2018-11-23
错误提示index文件出错
<template>
<div class="g-tabbar">
<router-link class="g-tabbar-item" to="/home">
<!-- 图标 -->
<i class="iconfont icon-home"></i>
<cpan>首页</cpan>
</router-link>
<router-link class="g-tabbar-item" to="/category">
<!-- 图标 -->
<i class="iconfont icon-category"></i>
<cpan>分类</cpan>
</router-link>
<router-link class="g-tabbar-item" to="/cart">
<!-- 图标 -->
<i class="iconfont icon-cart"></i>
<cpan>购物车</cpan>
</router-link>
<router-link class="g-tabbar-item" to="/personal">
<!-- 图标 -->
<i class="iconfont icon-personal"></i>
<cpan>个人中心</cpan>
</router-link>
</div>
</template>
<script>
export default {
name: 'CTabber'
}
</script>
<style lang="scss" scoped>
@import "~assets/scss/mixins";
.router-link-active{
color: $link-active-color;
}
</style>
lin5_mumu
提问者
2018-11-23
import Vue from 'vue'
import Router from 'vue-router'
// 引入页面的组件
import Home from 'pages/home'
// import Category from 'pages/category'
// import Cart from 'pages/cart'
// import Personal from 'pages/personal'
// import Search from 'pages/search'
// import Product from 'pages/product'
Vue.use(Router)
// 设置路径变量
const routes = [
{
name: 'home',
path: '/home',
component: () => import('pages/home'),
children: [
{
name: 'home-product',
path:'product/:id',
component: () => import('pages/product')
}
]
},
{
name: 'category',
path: '/category',
component: () => import('pages/category') ,
},
{
name: 'cart',
path: '/cart',
component: () => import('pages/cart'),
},
{
name: 'personal',
path: '/personal',
component: () => import('pages/personal'),
},
{
name: 'search',
path: '/search',
component: () => import('pages/search'),
},
// 设置输错以后进入home页面
{
path: '*',
component: Home,
}
]
export default new Router({
routes // ES写法直接写不需要使用键值对
})相似问题