liyongli 1 年之前
父節點
當前提交
bfb12e11ab
共有 1 個文件被更改,包括 10 次插入4 次删除
  1. 10 4
      src/components/playBtn.vue

+ 10 - 4
src/components/playBtn.vue

@@ -74,11 +74,17 @@ const play = () => {
     audio.pause();
   }
 };
+let a = 0;
+const touchendfunc = () => {
+  if (a === 1) {
+    document.removeEventListener('touchend',touchendfunc);
+    return;
+  }
+  audio && audio.play();
+  a = 1;
+};
 
-document.addEventListener('touchend' , ()=>{
-    audio && audio.play();
-})
-
+document.addEventListener('touchend', touchendfunc);
 </script>
 <style scoped>
 .imgbtn {