使用懒加载以后就报4个错,程序能运行,这是为什么?

来源:3-3 vue-router

lin5_mumu

2018-11-23 18:47:34

http://img.mukewang.com/climg/5bf7da6f0001ef6408780254.jpg

使用() => import('xxxxx')以后就一直会报4个错,说灭有正确定义自定义变量,但程序可以跑

写回答

3回答

好帮手慕糖

2018-11-23

同学你好,你是不是写错标签了,还是自定义了组件,就是cpan这个,若是自定义的组件的话,需要引用下哦。

http://img.mukewang.com/climg/5bf7dfb50001267204140298.jpg

祝学习愉快!

0
hin5_mumu
h 我天,看了一天电脑眼睛看花了,span写错了
h018-11-23
共1条回复

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>


0

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写法直接写不需要使用键值对
})


0

0 学习 · 3299 问题

查看课程