设置好了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]
好像是這樣![](http://img.php.cn/upload/image/000/000/000/0c0a626677d67dba83b05c2b03f3a798-0.png)
vue-router
你沒有貼App.vue中的程式碼 我不知道你寫了沒有
設定完路由之後
要在App.vue中引用路由路徑 這個content 大概的意思就是這個地方載入 你的Home.vue