vue项目mintui 日期插件滑动穿透事件

<span class="floatr birthspan rightspan"  @click="openPicker">{{birthdayval}}</span>

<mt-datetime-picker

                type="date"

                ref="picker"

                year-format="{value} 年"

                month-format="{value} 月"

                date-format="{value} 日"

                @confirm="handleConfirm"

                :startDate="startDate"

                :endDate = 'endDate'

                @cancel="checkinCancel"

             >

        </mt-datetime-picker>

data () {

    return {

        handler:function(e){e.preventDefault();},

    }

closeTouch:function(){

          document.getElementsByTagName("body")[0].addEventListener('touchmove',

            this.handler,{passive:false});//阻止默认事件  另,passive:false不清楚的可以百度addEventListener的参数

          console.log("closeTouch haved happened.");

        },

        openTouch:function(){

          document.getElementsByTagName("body")[0].removeEventListener('touchmove',

            this.handler,{passive:false});//打开默认事件

          console.log("openTouch haved happened.");

        },

openPicker () {

            this.$refs.picker.open()

            this.closeTouch();//关闭默认事件

        },

handleConfirm (data) {

        //自己的逻辑处理

            this.openTouch();//打开

        },

checkinCancel(){

          this.openTouch();//打开

      },



写在最后:若有点击蒙版关闭插件的事件记得this.openTouch();哦,

ps:很久之前在网上搜到的方法,找不到原文了,在此记录一下用法,侵删

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容