【ant design vue】解决Tabs选项卡打开时不选择第一个选项卡页

tips:ant design vue Tabs的activeKey只能是string,否则设置不起作用

 原因:缓存导致,当选择其他选项卡页时,关闭后,再次打开,还是会选择关闭前的选项卡页

解决:

利用activeKey

html代码:

 这里给选项卡设置activeKey值,然后通过change回调将每次选择后的key值赋值给activeKey

<a-tabs :activeKey="activeKey" @change="(key) => { this.activeKey = key }">
   <a-tab-pane key="0" tab="xx信息"></a-tab-pane>
   <a-tab-pane key="1" tab="yy信息"></a-tab-pane>
</a-tabs>

js代码: 

然后在打开选项卡的方法中,重置activeKey,使之选择第一个选项卡页

handleDetail(row){
    this.activeKey = '0';
    this.detailVisible = true;
},

猜你喜欢

转载自blog.csdn.net/THcoding_Cat/article/details/115214644