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

vue 綁定使用 touchstart touchmove touchend解析

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

綁定使用 touchstart touchmove touchend

今天要做一個(gè)頁面div長(zhǎng)按后觸發(fā)事件,簡(jiǎn)單學(xué)習(xí)后實(shí)現(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,按下并且在移動(dòng)呢')
? ? ? ? },
? ? ? ? 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é)果:

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

按下鼠標(biāo)不松開然后移動(dòng)會(huì)輸出2,

松開后就會(huì)輸出3,

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

解決touchstart touchend事件無效失效

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

增加 .native.prevent

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

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

相關(guān)文章

最新評(píng)論

克东县| 怀宁县| 遵义县| 措美县| 蛟河市| 修文县| 含山县| 温泉县| 邢台县| 遵化市| 湖州市| 洛宁县| 盐源县| 天水市| 太和县| 海安县| 兰溪市| 乌兰察布市| 都昌县| 陕西省| 洮南市| 绵阳市| 海林市| 宜昌市| 涿州市| 游戏| 长汀县| 长兴县| 手游| 乌兰县| 甘南县| 洛浦县| 邮箱| 绥江县| 嘉义市| 上犹县| 海城市| 黄陵县| 思南县| 霍林郭勒市| 霍邱县|