The mini program uses the pop-up component Modal to prevent bubbling events

Add a catchtap event to the modal component (it doesn't matter if you don't write any content in it), and it works in my own test!

<i-modal title="提示" visible="{
   
   { visible }}" catchtap="stopPropagation" bind:ok="call" bind:cancel="handleClose" ok-text="是" cancel-text="否">
    <view>是否拨打电话xxxxxxxxxxx?</view>
</i-modal>
/* 打电话 */
    handleOpen() {
      this.setData({
        visible: true
      });
    },
    handleClose() {
      this.setData({
        visible: false
      });
      return false;
    },
    call(){
      const phoneNumber = 'xxxxxxxxxxx';
      wx.makePhoneCall({
        phoneNumber,
        success: function(res) {},
        fail: function(res) {},
        complete: function(res) {},
      })
      this.setData({
        visible: false
      });
      return false;
    },
    /* 阻止冒泡事件 */
    stopPropagation(){
      return;
    }

 

Guess you like

Origin blog.csdn.net/ljy_1024/article/details/115917402