黑豹程序员-vue页面禁止鼠标拖动

//禁止页面拖动鼠标
import { onMounted, onBeforeUnmount } from ‘vue’;

onMounted(() => {
document.addEventListener(‘mousedown’, disableDrag);
document.addEventListener(‘touchstart’, disableDrag);
});

onBeforeUnmount(() => {
document.removeEventListener(‘mousedown’, disableDrag);
document.removeEventListener(‘touchstart’, disableDrag);
});

function disableDrag(event) {
event.preventDefault();
}

你可能感兴趣的:(黑豹程序员,Vue,vue.js,前端)