在router下的index.js
import Router from 'vue-router'
import Home from '@/pages/home/Home'
import City from '@/pages/city/City'
Vue.use(Router)
export default new Router({
routes: [
{
path: '/',
name: 'Home',
component: Home
},
{
path: '/city',
name: 'City',
component: City
}
]
})
组件home点击之后,跳转到city组件,所以在home设置
第一种跳转的方法:<router-link to="/city"></router-link>
home组件:
<template>
<div class="home">
<router-link to="/city">跳转</router-link>
</div>
</template>
第二种跳转的方法
methods:{
handlCityClick:function(){
this.$router.push("/city") //指定页
}
},