File tree 3 files changed +20
-12
lines changed
3 files changed +20
-12
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,6 @@ import ElementUI from 'element-ui'
7
7
// import Tui from '../../src/components/baseComponents/index.js'
8
8
import Tui from '../../packages'
9
9
import { message } from './public/utils/resetMessage' // 防止重复点击重复弹出message弹框
10
- import vueClipboard from 'vue-clipboard2'
11
10
// import * as filters from './public/utils/filters' // global filters
12
11
import './public/utils/directives' // 自定义指令
13
12
import 'element-ui/lib/theme-chalk/index.css'
@@ -23,7 +22,6 @@ export default ({
23
22
Vue . use ( VueHighlightJS ) ,
24
23
Vue . use ( ElementUI ) ,
25
24
Vue . use ( Tui ) ,
26
- Vue . use ( vueClipboard ) ,
27
25
Vue . prototype . $messageUpload = message ,
28
26
Vue . prototype . $message = ElementUI . Message ,
29
27
Vue . prototype . $loading = ElementUI . Loading . service ,
Original file line number Diff line number Diff line change @@ -13,7 +13,6 @@ import '@/directive'
13
13
import * as filters from './utils/filters' // global filters
14
14
import { message } from './utils/resetMessage' // 防止重复点击重复弹出message弹框
15
15
import api from '@/api' // 接口api
16
- import VueClipboard from 'vue-clipboard2' // 复制插件
17
16
// import { Message } from 'element-ui'
18
17
19
18
import Tui from '../packages' // 二次封装组件
@@ -24,7 +23,6 @@ Vue.use(vueSeamlessScroll)
24
23
Vue . use ( Element )
25
24
Vue . use ( Tui )
26
25
27
- Vue . use ( VueClipboard )
28
26
29
27
Vue . prototype . $http = api
30
28
Vue . prototype . $messageUpload = message
Original file line number Diff line number Diff line change @@ -1263,6 +1263,20 @@ export default {
1263
1263
< / div>
1264
1264
)
1265
1265
},
1266
+ // 复制内容
1267
+ copyDomText (val ) {
1268
+ // 获取需要复制的元素以及元素内的文本内容
1269
+ const text = val
1270
+ // 添加一个input元素放置需要的文本内容
1271
+ const input = document .createElement (' input' )
1272
+ input .value = text
1273
+ document .body .appendChild (input)
1274
+ // 选中并复制文本到剪切板
1275
+ input .select ()
1276
+ document .execCommand (' copy' )
1277
+ // 移除input元素
1278
+ document .body .removeChild (input)
1279
+ },
1266
1280
// 双击复制单元格内容
1267
1281
cellDblclick (row , column ) {
1268
1282
if (! this .isCopy ) {
@@ -1276,14 +1290,12 @@ export default {
1276
1290
} else {
1277
1291
label = row[column .property ]
1278
1292
}
1279
- this .$copyText (label).then (
1280
- () => {
1281
- this .$message .success (' 已复制' )
1282
- },
1283
- () => {
1284
- this .$message .error (' 复制失败' )
1285
- }
1286
- )
1293
+ try {
1294
+ this .copyDomText (label)
1295
+ this .$message .success (' 已复制' )
1296
+ } catch (e) {
1297
+ this .$message .error (' 复制失败' )
1298
+ }
1287
1299
},
1288
1300
// 是否显示表格操作按钮
1289
1301
checkIsShow (scope , item ) {
You can’t perform that action at this time.
0 commit comments