0.新建一個組件Brand
1.在router/index.js中添加
//導入
import Brand from '@/components/Brand'
//在routes中添加
{
path: '/brand',
name: 'Brand',
component: Brand
}
2.在父頁面中添加
//用來替代組件
<router-view/>
//點擊觸發(fā)替換
//to="/brand"為router中定義的路徑,“品牌”為連接顯示的名稱
//頁面加載是默認把<router-view/>替換為路徑為"/"的頁面
<router-link to="/brand">品牌</router-link>
3.代碼導航(子組件替換)
this.$router.push({path: '/brand'})