<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:很久之前在网上搜到的方法,找不到原文了,在此记录一下用法,侵删