设置好了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]
PHP中文网2017-04-17 16:40:31
You didn’t post the code in App.vue. I don’t know if you wrote it
Vue.use(Router)
Vue.use(Vuex)
export default new Router({
routes: [
{
path: '/',
component: App,
redirect:'/in_theaters'},
{
path: '/in_theaters',
component: in_theaters,
},{
path: '/coming_soon',
component: coming_soon,
},
{
path: '/top250',
component: top250,
},
{
path:'*',
redirect:'/'
}
]
})
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
<el-col :md="14" :lg="18" class="content">
<router-view></router-view>
</el-col>