mui是通過mui-active的class屬性來表示激活狀態(改變該按鈕的顏色)
<router-link class="mui-tab-item mui-active" :to="{name:'member'}">
<span class="mui-icon icon-myhuiyuan"></span>
<span class="mui-tab-label">會員</span>
</router-link>
配合router-link的linkActiveClass屬性,就能在每次點擊后並且跳轉后,改變樣式。
let router = new VueRouter({ linkActiveClass:'mui-active', //router-link成功后,就給該按鈕加上mui-active屬性。 routes: [ //VueRouter:配置路由規則
{ path: '/', redirect: { name: 'home' } }, //重定向
{ name: 'home', path: '/home', component: Home },//首頁
{ name:'member',path:'/member',component: Member}, //會員
{ name: 'shopcart',path:'/shopcart',component:Shopcart}, //購物車
{ name: 'search',path:'/search',component:Search}, //查找
{ name:'news.list',path:'/news/list',component:NewsList}, //新聞列表
{ name:'news.detail',path:'/news/detail',component:NewsDetail}, //新聞詳情
] });