问题一:配置main.js,vue-router中router-view无法渲染,采用如下方式配置:
Vue.use(VueRouter)
const routes=[{
path:'/',
component:home
},{
path:"/hello",
component:Hello
}]
const router = new VueRouter({
routes
})
new Vue({
el: '#app',
router,
template:"<App/>",
components:{
App
}
})
在定义路由数组时,该数组名称请以routes命名,若命名不是这个,会导致渲染错误,也可以参考如下方式:
const r=[{
path:'/',
component:home
},{
path:"/hello",
component:Hello
}]
const router = new VueRouter({
routes`**重点内容**r
})