最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

vue 綁定使用 touchstart touchmove touchend解析

 更新時間:2022年03月28日 09:36:50   作者:<s>LoCloudy</s>  
這篇文章主要介紹了vue 綁定使用 touchstart touchmove touchend解析,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教

綁定使用 touchstart touchmove touchend

今天要做一個頁面div長按后觸發(fā)事件,簡單學習后實現(xiàn)如下:

先看代碼:

<template>
? <div>
? ? <div class="test" @touchstart="gtouchstart()" @touchmove="gtouchmove()" @touchend="gtouchend()">試一試呀!</div>
? </div>
</template>
<script>
export default {
? data () {
? ? return {? ? ? ??
? ? }
? },
? ? methods:{
? ? ? ? gtouchstart(){
? ? ? ? ? ? window.console.log('1,按下啦啦啦啦啦')
? ? ? ? },
? ? ? ? gtouchmove(){
? ? ? ? ? ? window.console.log('2,按下并且在移動呢')
? ? ? ? },
? ? ? ? gtouchend(){
? ? ? ? ? ? window.console.log('3,松開啦啦啦啦啦')
? ? ? ? }
? ? }
}
</script>
<style scoped>
? ? .test{
? ? ? ? width: 100%;
? ? ? ? height: 50px;;
? ? ? ? text-align: center;
? ? ? ? background-color: red;
? ? ? ? line-height: 50px;
? ? ? ? font-size: 50px;
? ? }?
</style>

看結(jié)果:

鼠標在紅色區(qū)域內(nèi)按下會輸出1,

按下鼠標不松開然后移動會輸出2,

松開后就會輸出3,

根據(jù)自己的情況在三個函數(shù)里寫入相應的功能。

解決touchstart touchend事件無效失效

?? ?<van-button
? ? ? ? ? :disabled="isLoading"
? ? ? ? ? plain
? ? ? ? ? type="info"
? ? ? ? ? @touchstart.native.prevent="touchstart"
? ? ? ? ? @touchend.native.prevent="touchend"
? ? ? ? ? style="width:40%;height: 40px;"
? ? ? ? ? round>對比原圖
? ? ? ? </van-button>
@touchstart.native.prevent=“touchstart”
@touchend.native.prevent=“touchend”

增加 .native.prevent

? ? touchstart() {
? ? ? console.log('touchstart')
? ? },
? ? touchend() {
? ? ? console.log('touchend')
? ? },

以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論

黄大仙区| 新民市| 韩城市| 九寨沟县| 砀山县| 慈溪市| 龙山县| 富源县| 井研县| 广水市| 大余县| 杭锦旗| 崇仁县| 孝义市| 乐东| 文昌市| 洛宁县| 兰坪| 固始县| 昌图县| 南澳县| 宁晋县| 新乡县| 兴宁市| 罗平县| 资源县| 陆良县| 旺苍县| 林州市| 怀柔区| 伊金霍洛旗| 咸阳市| 新绛县| 广州市| 含山县| 亚东县| 西和县| 东辽县| 华宁县| 大埔县| 玉田县|