Where should I write Router.push("/good")?

来源:15-5 Vue-router(下)

weibo_Gingbery_0

2017-05-15

I put the router file in "src/router/index.js",and where should I write Router.push("/good")?I have tried writed it in index.js or main.js,neither did it work....below is the router filehttp://szimg.mukewang.com/5919c92700013eef07300700.jpg

写回答

3回答

ustbhuangyi

2017-05-16

use redirect instead, here is the code:

const routes = [{    

path: '/',    

redirect: '/goods'    

}, {    

path: '/goods',    

component: goods    

}, {    

path: '/ratings',    

component: ratings    

}, {    

path: '/seller',    

component: seller    

}];    

0
2
weibo_Gingbery_0
I got another problem.I configured the router in this way and when the "tab-item"was clicked and activated,they just wouldn't be added "link-active-class" automatically. I've searched possible causes and got nothing....
2017-05-16
共2条回复

ustbhuangyi

2017-05-16

try '/goods' and  the template is:  <router-link to="/goods">商品</router-link>

0
0

weibo_Gingbery_0

提问者

2017-05-16

I've solved this prolem by 

export default new Router({
  routes: [
    {
      path: '/',
      redirect:{name:'goods'}
    },


0
0

Vue.js2.5+cube-ui重构饿了么App(经典再升级)

掌握Vue1.0到2.0再到2.5最全版本应用与迭代,打造极致流畅的WebApp

9868 学习 · 4162 问题

查看课程