设置好了vue路由,npm run dev一下,不报错,但是路由不生效啊
代码如下:
//引入路由模块
import VueRouter from 'vue-router'
//使用路由模块
Vue.use(VueRouter);
//加载组件
import home from './components/Home/home.vue';
//创建路由对象
const router = new VueRouter({
//配置router-link 指向的路由发生变化时候,当前a标签增加的激活样式
routes: [
{name: 'Home', path: '/home', component: home},
]
})
var vm = new Vue({
el: '#app',
render: h => h(app), //h 是 createElement这个函数 编译app.vue组件
//使用路由对象
router: router
});`请输入代码`
还有:
<template>
<p class="mui-content">
home
</p>
</template>
<script>
export default {
data () {
return{
}
}
}
</script>
<style scoped>
</style>
图片:
![图片描述][1]
It seems like this
vue-router
You didn’t post the code in App.vue. I don’t know if you wrote it
After configuring the routing,
refer to the routing path in App.vue. This content probably means that this is where your Home.vue is loaded