export function addDirective(app) {
/**
* 拖拽指令使用方式:v-drag="[dragDom, dragHeader]",如 ``
*/
app.directive('drag', {
mounted(el, binding) {
if (!binding.value) return false;
binding.instance.$nextTick(() => {
const dragDom = document.querySelector(binding.value[0])
const dragHeader = document.querySelector(binding.value[1])
dragHeader.onmouseover = () => (dragHeader.style.cursor = `move`);
function down(e, type) {
// 鼠标按下,计算当前元素距离可视区的距离
const disX = type === 'pc' ? e.clientX - dragHeader.offsetLeft : e.touches[0].clientX - dragHeader.offsetLeft;
const disY = type === 'pc' ? e.clientY - dragHeader.of
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)