When a package assembly error Unknown custom element: router-view make sure to provide the name option.

When configuring the project route, using a router-view can not be properly rendered, being given as follows: [Vue warn]: Unknown custom element: - did you register the component correctly For recursive components, make sure to provide the "name" option?.

found in

—> at src/App.vue

Check the following routing configuration file index.js:

import Vue from 'vue
import VueRouter from 'vue-router'

//懒加载
const Home=()=>import('../views/home/Home.vue')
const Category=()=>import('../views/category/Category.vue')
const Cart=()=>import('../views/cart/Cart.vue')
const Profile=()=>import('../views/profile/Profile.vue')

Vue.use(VueRouter)

const routes=[
  {
    path:'',
    redirect:'/home'
  },
  {
    path:'/home',
    component:Home
  },
  {
    path:'/category',
    component:Category
  },
  {
    path:'/cart',
    component:Cart
  },
  {
    path:'/profile',
    component:Profile
  },

]
const router =new VueRouter({
  routes
})
export default router

After writing correctly, ask after the old man of the group, was found in the entry file main.js

import Vue from 'vue'
import App from './App'


Vue.config.productionTip = false

/* eslint-disable no-new */
new Vue({
  el: '#app',

  render: h => h(App)
})


Forget the registered components! ! ! !

Modified as follows:

import Vue from 'vue'
import App from './App'
import router from './router'

Vue.config.productionTip = false

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  render: h => h(App)
})

The brainless little mistakes do not want to do it again.

Released two original articles · won praise 0 · Views 22

Guess you like

Origin blog.csdn.net/SDAW_1/article/details/104114659