微信小程序踩坑4

TypeError: this.swipeaction.closeOther is not a function

问题描述:使用uni-swipe-action和uni-swipe-action-item组件,点击侧滑按钮后报错

<uni-swipe-action>
      <block v-for="(goods, i) in cart" :key="i">
            <uni-swipe-action-item :right-options="options" @click="">
                   <my-goods
                        :goods="goods" 
                        :show-radio="true" 
                        :show-num="true"
                        @radio-change="radioChangeHandler" 
                        @num-change="numberChangeHandler"
                   >
                   </my-goods>
             </uni-swipe-action-item>    
      </block>
 </uni-swipe-action>

错误是:
在这里插入图片描述
解决方式:
进入 uni-modules/uni-swipe-action/uni-swipe-action-item/mpwxs.js,在methods找到closeSwipe

// wxs 中调用
closeSwipe(e) {
	if (!this.autoClose) return
	this.swipeaction.closeOther(this)            
},

改为如下:

// wxs 中调用
closeSwipe(e) {
	if (!this.autoClose) return
	// #ifdef H5 
	this.swipeaction.closeOther(this)  
	// #endif          
},

就可以解决了。


版权声明:本文为qq_38393535原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。