admin管理员组文章数量:1430358
The question says it all but I have 3 tabs in Buefy, the first two (summary and details) I have got covered and work correctly as expected but the third tab is a logout button so when I click it I want to fire a method to alert("").
My buefy tabs are just from the standard page here and look like:
<b-tabs type="is-toggle" expanded>
<b-tab-item label="Pictures" icon="google-photos"></b-tab-item>
<b-tab-item label="Music" icon="library-music"></b-tab-item>
<b-tab-item label="Logout" icon="logout"></b-tab-item>
</b-tabs>
The question says it all but I have 3 tabs in Buefy, the first two (summary and details) I have got covered and work correctly as expected but the third tab is a logout button so when I click it I want to fire a method to alert("").
My buefy tabs are just from the standard page here and look like:
<b-tabs type="is-toggle" expanded>
<b-tab-item label="Pictures" icon="google-photos"></b-tab-item>
<b-tab-item label="Music" icon="library-music"></b-tab-item>
<b-tab-item label="Logout" icon="logout"></b-tab-item>
</b-tabs>
I have tried putting an on-click into the b-tab-item but that didn't work and the docs say there is an event:
input Triggers when tab is clicked index: Number
But I don't know how to capture that the third tab has been clicked to fire some code.
Share Improve this question asked May 29, 2019 at 22:30 Johnny John BoyJohnny John Boy 3,2946 gold badges33 silver badges58 bronze badges1 Answer
Reset to default 7As with all Vue event handlers, the @input event handler will automatically pass the event data to your methods. In this case, as the docs state, that event data is simply the index of the button tab clicked.
<template>
<b-tabs v-model="activeTab" type="is-boxed" @input="tabClicked(activeTab)"
<b-tab-item label="Pictures" icon="google-photos"></b-tab-item>
<b-tab-item label="Music" icon="library-music"></b-tab-item>
<b-tab-item label="Videos" icon="video"></b-tab-item>
</b-tabs>
</template>
<script>
export default {
data() {
return {
activeTab: 0,
};
},
methods: {
tabClicked(index) {
if (index === 2) alert('Index 2 is the third button');
},
},
};
</script>
本文标签: javascriptHow to trigger method when clicking a Buefy tabsStack Overflow
版权声明:本文标题:javascript - How to trigger method when clicking a Buefy tabs? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745439636a2658386.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论