field-copy.vue
852 Bytes
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<template>
<view class="field-copy" @click.stop="onCopy">
<slot></slot>
<view class="img">
<image src="/static/copy-icon.png"></image>
</view>
</view>
</template>
<script>
export default {
name:'fieldCopy',
props: {
value: [String, Number]
},
methods: {
// 复制
onCopy: async function () {
if (this.value) {
uni.setClipboardData({
data: this.value,
success: function () {
uni.showToast({ icon: 'success', title: '已复制' });
},
});
}
},
},
};
</script>
<style lang="scss">
.field-copy {
display: inline-block;
min-width: 40upx;
.img {
display: inline-block;
width: 26rpx;
height: 26rpx;
margin-left: 8rpx;
image {
width: 100%;
height: 100%;
vertical-align: middle;
}
}
}
</style>