使用js实现标题跳转与复制实现方法
# html 部分
<span v-html="dataObj.html" @mousemove="handleOnMousemove($event, dataObj)" @mouseup="handleOnMouseup($event, dataObj)" @dblclick="handleOnDblclick($event, dataObj)" :id="dataObj.id"></span>
1
# js 部分
handleOnMousemove(e, item) {
if (this.isMousedown) {
// console.log(e);
document.getElementById(item.id).style.cursor = 'text'
}
},
handleOnDblclick() {
this.isDblclick = true;
// console.log(this.x);
},
handleOnMousedown(e) {
this.x = e.x;
this.isMousedown = true;
// console.log(this.x);
},
handleOnMouseup(e, item) {
let x = e.x
this.isMousedown = false;
document.getElementById(item.id).style.cursor = 'pointer'
if (Math.abs(this.x - x) > 2) {
// console.log('复制');
} else {
clearTimeout(this.timer);
this.timer = setTimeout(() => {
if (this.isDblclick) {
// console.log('双击');
this.isDblclick = false;
// console.log('复制');
} else {
// console.log('跳转');
}
}, 300);
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
上次更新: 2024/03/02, 18:23:00
- 02
- Node与GLIBC_2.27不兼容解决方案08-19
- 03
- Git清空本地文件跟踪缓存08-13