場景:有head和foot,爲父組件
側欄tree爲子組件
點擊tree,右側孫組件根據點擊tree的id,來更改表格內容。
javascript
export default new Router({ routes: [ { path: '/', redirect: { name: '首頁' }, component: cmshome,//父組件 children: [ { path: '/', component: cmsindex, name: 'cmsindex' }, { path: '/projects', component: projects, name: 'projects' }, { path: '/project', component: projecthome,name: 'projecthome',//子組件 children: [ {path: '/project', component: project, name: 'project'}//孫組件 ] }, ] },
<router-view :tree-id="treeId"></router-view>
props:['treeId'],
watch: { // 若是 question 發生改變,這個函數就會運行 treeId: function (newQuestion) { this.projproducts(this.currentPage); } },