在配合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. 集合Arraylist的方法的使用和打印

    package chapter090; import java.util.ArrayList;import java.util.List; public class TestList01 { publ ...

  2. javafx的scene大小不能在控制器中设置

    做个记录,备忘 遇到一个问题,点击提交,红色标识的VBox大小不能改变.问题如图,代码如下 点击后 fxml结构简化代码: 红色框体对应vboxMax <VBox fx:id="vbo ...

  3. 删除一个存在的RabbitMQ队列

    import sys # pip install kafka-python sys.path.append("/usr/local/software/ELK") from Util ...

  4. (第1篇)什么是hadoop大数据?我又为什么要写这篇文章?

    摘要: hadoop是什么?hadoop是如何发展起来的?怎样才能正确安装hadoop环境? 这些天,有很多人咨询我大数据相关的一些信息,觉得大数据再未来会是一个朝阳行业,希望能尽早学会.入行,借这个 ...

  5. streaming优化:spark.streaming.receiver.maxRate

    使用spark.streaming.receiver.maxRate来限制你的吞吐的最大信息量. 因为当streaming程序的数据源的数据量突然变大巨大,可能会导致streaming被撑住导致吞吐不 ...

  6. KAFKA的安装使用

    一:介绍 1.官网 kafka.apache.org 2.产生 Kafka由 linked-in 开源  kafka-即是解决上述这类问题的一个框架,它实现了生产者和消费者之间的无缝连接.  kafk ...

  7. Digital biquad filter

    Direct Form 1 The most straightforward implementation is the Direct Form 1, which has the following ...

  8. Windows 修改host文件

    在实际的开发中,有时我们会修改windows的hosts文件,达到指定域名映射到指定ip上的功能.修改方式如下: 1. windows 中hosts文件位置(win10): C:\Windows\Sy ...

  9. 8.9 正睿暑期集训营 Day6 C 风花雪月(DP)

    题目链接 完整比赛在这儿. 杜老师tql . 求期望要抽卡的次数,也就是求期望经历了多少不满足状态.而每个不满足的状态对答案的贡献为\(1\),所以可以直接算概率.即\(Ans=\sum_{不满足状态 ...

  10. 卡特兰数 Catalan 笔记

    一.公式 卡特兰数一般公式 令h(0)=1,h(1)=1,catalan数满足递推式.h(n) = h(0)*h(n-1)+h(1)*h(n-2) + ... + h(n-1)h(0) (n>= ...