vue在使用mint-ui的TabContainer功能时swipeable参数不知如何使用?

发布于 2022-09-05 11:03:05 字数 2019 浏览 15 评论 0

1.在项目中使用mint-ui的TabContainer组件时,想要实现左右切换tab,swipeable参数不知如何使用?

<template>
    <div>
        <div class="nav">
            <mt-button size="small" @click="test('tab-container1')">tab 1</mt-button>
            <!--<mt-button size="small" @click="active = 'tab-container1'">tab 1</mt-button>-->
            <mt-button size="small" @click="test('tab-container2')">tab 2</mt-button>
            <mt-button size="small" @click="test('tab-container3')">tab 3</mt-button>
        </div>
        <div class="page-tab-container" >
            <mt-tab-container class="page-tabbar-tab-container" v-model="active" swipeable value="tab-container1">
                <mt-tab-container-item id="tab-container1" >
                    <mt-cell :key="n" v-for="n in 10" title="tab-container 1" ></mt-cell>
                </mt-tab-container-item>
                <mt-tab-container-item id="tab-container2">
                    <mt-cell :key="n" v-for="n in 5" title="tab-container 2" ></mt-cell>
                </mt-tab-container-item>
                <mt-tab-container-item id="tab-container3" >
                    <mt-cell :key="n" v-for="n in 7" title="tab-container 3" ></mt-cell>
                </mt-tab-container-item>
            </mt-tab-container>
        </div>
    </div>
</template>
<script>
    export default {
        name: 'page-tab-container',
        data() {
            return {
                active: "tab-container1",
                // swipeable: true
            };
        },
        methods:{
            test(id){
                this.active = id
                console.log(this.active)
            }
        }
    };
</script>

代码如上,如果没有swipeable这个参数,则能够点击切换,如果加上了,则可以切换,但是显示的有问题,并且点击切换也不行了。
请问应该如何才能既有点击切换又有左右滑动切换?谢谢

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

听,心雨的声音 2022-09-12 11:03:05

可以使用vue的watch监听mt-tab-container组件的参数并做相应的改变。

watch:{
  active:function (newValue) {
    // active即为mt-tab-container的参数,这里监听它的改变并可以做相关操作:
    // 在你的tabBar组件点击的时候更改active的值
    // 滑动mt-tab-container-item组件即更改active的值,监听newValue的变化并操作你的tabBar,使得点击切换和滑动切换相关联
  }
}
ぽ尐不点ル 2022-09-12 11:03:05
<mt-tab-container class="page-tabbar-tab-container" v-model="active" :swipeable='true' value="tab-container1">
猛虎独行 2022-09-12 11:03:05

楼主解决那个tab切换问题了吗?我也遇到了一样的问题,如果解决了可以分享一下吗?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文