在配合require.js使用vue路由的时候,遇到了路由组件报错:

“vue.js:597 [Vue warn]: Unknown custom element: <router-link> - did you register the component correctly? For recursive components, make sure to provide the "name" option.”

vue.js的功能是好的,vue-route.js没有起作用,这是怎么回事?明明文件也被加载进来了呀。

如果做如下修改就可以了,在router.js中增加

Vue.use(VueRouter) 就可以避免报这个错误
import Vue from 'vue'
import VueRouter from 'vue-router' import HomeContainer from './components/lib/HomeContainer.vue'
import MemberContainer from './components/lib/MemberContainer.vue'
import ShopcarContainer from './components/lib/ShopcarContainer.vue'
import SearchContainer from './components/lib/SearchContainer.vue' Vue.use(VueRouter) var router = new VueRouter({
routes:[
{path:'/home', component: HomeContainer},
{path:'/member', component: MemberContainer},
{path:'/shopcar', component: ShopcarContainer},
{path:'/search', component: SearchContainer}
],
linkActiveClass:'mui-active'
}) export default router

不过这不是和main.js中加载重复了嘛?不知道是架构问题还是工具问题。目前暂时是这个解决方案:

main.js

// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import './lib/css/mui.min.css'
import './lib/css/icons-extra.css'
import 'mint-ui/lib/style.css'
import { Header } from 'mint-ui'; import router from './router' Vue.config.productionTip = false Vue.component(Header.name, Header); /* eslint-disable no-new */
new Vue({
render: h => h(App),
router
}).$mount('#app');

其中APP.vue

<template>
<div class="app-container">
<mt-header fixed title="固定在顶部"></mt-header> <router-view></router-view> <nav class="mui-bar mui-bar-tab">
<router-link class="mui-tab-item" to="/home">
<span class="mui-icon mui-icon-home"></span>
<span class="mui-tab-label">首页</span>
</router-link>
<router-link class="mui-tab-item" to="/member">
<span class="mui-icon mui-icon-contact"></span>
<span class="mui-tab-label">会员</span>
</router-link>
<router-link class="mui-tab-item" to="/shopcar">
<span class="mui-icon mui-icon-extra mui-icon-extra-cart"><span class="mui-badge">0</span></span>
<span class="mui-tab-label">购物车</span>
</router-link>
<router-link class="mui-tab-item" to="/search">
<span class="mui-icon mui-icon-search"></span>
<span class="mui-tab-label">搜索</span>
</router-link>
</nav>
</div>
</template> <script> </script> <style scoped>
.app-container{
padding-top: 40px;
}
</style>

使用vue.js路由踩到的一个坑Unknown custom element的更多相关文章

  1. Vue组件化应用构建 官网例子 Unknown custom element: <todo-item>

     [博客园cnblogs笔者m-yb原创,转载请加本文博客链接,笔者github: https://github.com/mayangbo666,公众号aandb7,QQ群927113708] htt ...

  2. Vue.js 入门:从零开始做一个极简 To-Do 应用

    Vue.js 入门:从零开始做一个极简 To-Do 应用 写作时间:2019-12-10版本信息:Vue.js 2.6.10官网文档:https://cn.vuejs.org/ 前言  学习 Vue ...

  3. (错误记录)Vue: Unknown custom element

    错误: vue.js:634 [Vue warn]: Unknown custom element: <ve-pie> - did you register the component c ...

  4. vue报错[Vue warn]: Unknown custom element: <router-Link> - did you register the component correctly? For recursive components, make sure to provide the "name" option.

    vue浏览器报错,如下 vue.runtime.esm.js?2b0e:619 [Vue warn]: Unknown custom element: <router-Link> - di ...

  5. vue components registration & vue error & Unknown custom element

    vue components registration & vue error & Unknown custom element vue.esm.js:629 [Vue warn]: ...

  6. Vue报错之" [Vue warn]: Unknown custom element: <wzwzihello> - did you register the component correctly? For recursive components, make sure to provide the "name" option."

    一.报错截图 [Vue warn]: Unknown custom element: <wzwzihello> - did you register the component corre ...

  7. [Vue warn]: Unknown custom element: <sapn> - did you register the component correctly? For recursive components, make sure to provide the "name" option. found in ---> <Evaluate> at src/views/index/

    关于vue报错: [Vue warn]: Unknown custom element: <sapn> - did you register the component correctly ...

  8. vue.js路由参数简单实例讲解------简单易懂

    vue中,我们构建单页面应用时候,一定必不可少用到vue-router vue-router 就是我们的路由,这个由vue官方提供的插件 首先在我们项目中安装vue-router路由依赖 第一种,我们 ...

  9. Vue.js路由

    有时候,我们在用vue的时候会有这样的需求,比如一个管理系统,点了左边的菜单栏,右边跳转到一个新的页面中,而且刷新的时候还会停留在原来打开的页面. 又或者,一个页面中几个不同的画面来回点击切换,这两种 ...

随机推荐

  1. 【C++ Primer 第11章 练习答案】2. 关联容器概述

    11.2.1节练习 [练习11.7]代码: #include<iostream> #include<string> #include<vector> #includ ...

  2. DB操作-用批处理执行Sql语句

    用批处理在命令行状态下调用查询分析器来执行这个sql文件里的语句.下面就是sqlserver帮助里对于查询分析器(isqlw)命令行参数的解释:isqlw 实用工具(SQL 查询分析器)使您得以输入 ...

  3. 微服务的发现与注册--Eureka

    目录 服务提供者.服务消费者.服务发现组件三者之间的关系 Eureka 简介 Eureka Server Eureka Client 编写Eureka Server 将微服务注册到Eureka Ser ...

  4. spoj694

    题意:求不相同的子串个数 题解: 考虑一下后缀数组 yy一下就能发现答案就是n*(n+1)/2-sigma(i=1;i<=n;i++)height[i] 代码:

  5. 三步解决阿里云绑定公网IP地址失败解决方案

    1.客户端设置为阿里云服务器的公有地址: 2.服务端设置为阿里云服务器的私有地址: 3.设置阿里云的管理规则: 第一步 第二步 第三.四步

  6. python全栈开发day20-类的三大特性继承、多态、封装

    1 继承 1.怎么继承,父类和子类 class 类名(父类):pass 除了__init__下对象属性不能自动继承外,其他的类属性和动态方法,子类对象都可以访问到. 2.子类对象查找属性的顺序,对象现 ...

  7. BZOJ1059 [ZJOI2007]矩阵游戏 二分图匹配 匈牙利算法

    欢迎访问~原文出处——博客园-zhouzhendong 去博客园看该题解 题目传送门 - BZOJ1059 题意概括 有一个n*n(n<=200)的01矩阵,问你是否可以通过交换整行和整列使得左 ...

  8. 通过工具SecureCRTPortable将项目部署到服务器上

    1.将项目打包 2.打开工具连接指定的ip 下面是一些命令 tab键可以有一些提示功能 ls 查看服务器当前目录 lls 查看硬盘当前目录 其实就是linux系统命令 ,服务器是正常命令  ,操作本电 ...

  9. MSF《构建之法》阅读笔记5

    第七章 MSF MSF是一种软件开发方法,MSF原则包括1推动信息共享和沟通,2为共同的远景而工作,3充分授权和信任,4各司其职,对项目共同负责,5交付增量的价值,6保持敏捷,预期和适应变化,7投资质 ...

  10. 003 将spark源码导入到IDEA中

    1.解压源代码 2.进入IDEA的首界面 3.使用open将解压的工程加载 4.将文件的形式改成maven项目 5.使用