better-scroll 2.0.4版本,给内部标签添加点击事件,会执行两次
来源:13-2 编译打包-项目编译打包及node服务测试
Hecocacola
2020-09-27
看了issue和慕课问题,但是没有解决呢
写回答
2回答
-
Hecocacola
提问者
2020-09-27
// 页面 <template> <div class="avtive-center"> <scroll class="active-content" :data="activeList"> <div> <div class="banner" @click="to"> <img src="../assets/images/active-banner.png" alt="" /> </div> <div class="active-center-lists"> <template v-for="(item, index) in activeList"> <active-list :activeList="item" :key="index"></active-list> </template> </div> </div> </scroll> </div> </template> // scroll 组件 <template> <div ref="wrapper"> <slot></slot> </div> </template> <script> import BScroll from "better-scroll"; export default { props: { probeType: { type: Number, default: 1, }, click: { type: Boolean, default: true, }, data: { type: Array, default: [], }, refreshDelay: { type: Number, default: 20, }, }, watch: { data() { setTimeout(() => { this._initScroll(); }, this.refreshDelay); }, }, mounted() { setTimeout(() => { this._initScroll(); }, 20); }, methods: { _initScroll() { if (!this.$refs.wrapper) { return; } this.scroll = new BScroll(this.$refs.wrapper, { probeType: this.probeType, click: this.click, scrollX: true, }); }, enable() { // 如果这个this.scroll 是有的,就调用this.scroll.enable() this.scroll && this.scroll.enable(); }, disable() { this.scroll && this.scroll.disable(); }, refresh() { this.scroll && this.scroll.refresh(); }, }, }; </script> <style lang="less" scoped></style>
00 -
ustbhuangyi
2020-09-27
套了 2 层 scroll 吗
082020-09-28
相似问题