#Vue手动封装可拖拽图标组件
1.新建组件并引用组件
<floatIcon v-show="showAI" ref="fu"></floatIcon>
import floatIcon from "./components/floatIcon.vue";
2.组件相关代码
<template>
<div>
<a @click="GoToAI" @mousedown="down" @touchstart="down" @mousemove="move" @touchmove="move" @mouseup="end" @touchend="end" ref="fu" class="float">
<img style="width: .8rem;" src="../assets/imgs/aiIcon.png" alt="">
</a>
</div>
</template>
<script>
export default {
name:'',
props: {
},
data () {
return {
flags: false,//控制使用
position: {
x: 0,
y: 0
},
nx: '',
ny: '',
dx: '',
dy: '',
xPum: '',
yPum: '',
}
},
watch:{
},
mounted() {
},
methods:{
GoToAI(){
this.$router.push('/AI');
},
// @mousedown @touchstart PC端和移动端的方法
// @mousemove @touchmove
// @mouseup @touchend
down() {
this.flags = true;
var touch;
if (event.touches) {
touch

最低0.47元/天 解锁文章
1020

被折叠的 条评论
为什么被折叠?



