问题来源:
element-ui的tab标签下面有两个pane,一个显示,一个隐藏,每个pane里面都有一个router-view,但是每次加载时隐藏的router-view也会被触发。
<a-tabs
v-model="activeKey"
type="editable-card"
hideAdd
@edit="onEdit"
@change="tabClick"
@tab-remove="remove"
>
<a-tab-pane
v-for="pane in panes"
:key="pane.key"
:tab="pane.title"
:closable="pane.closable"
:name="pane.content"
>
<keep-alive>
<router-view
:name="pane.content"
:ref="pane.content"
:menuPositionId="activeKey"
:activeKey="menuPositionId"
></router-view>
</keep-alive>
</a-tab-pane>
</a-tabs>
export default new Router({
routes: [
{
path: '/',
name: 'index',
// component: resolve => require([ '../components/index/index' ], resolve),
component: index,
children: [
{
path: '/CargoOwnerManagement',
name: 'CargoOwnerManagement',
components: {CargoOwnerManagement:function(resolve) {require(['../components/BasicInformationManagement/CargoOwnerManagement'], resolve)}}
},
{
path: '/addressConfiguration',
name: 'addressConfiguration',
components: {addressConfiguration:function(resolve) {require(['../components/addressTypeAdministration/addressConfiguration'], resolve)}}
},
]
}
]
)}
解决方法:
给每个router-view加一个name属性,router里面的index.js也进行相应配置。