Clipboard 复制剪切板
... 2021-7-29 Less than 1 minute
Tips
1.0.6+
<div style="width:400px">
<div style="margin-bottom:10px">
<el-button @click="copy">直接复制</el-button>
<el-button @click="textarea=''">清 空</el-button>
</div>
<el-input placeholder="内容" v-model="text">
<template slot="append">
<el-button @click="copyText" color="primary">复制</el-button>
</template>
</el-input>
<div style="margin-top:10px">
<el-input type="textarea" v-model="textarea" cols="40" rows="3"></el-input>
</div>
</div>
<script>
export default {
data() {
return {
text: '',
textarea: ''
}
},
methods: {
copyText() {
this.$Clipboard({
text: this.text
}).then(() => {
this.$message.success('复制成功')
}).catch(() => {
this.$message.error('复制失败')
});
},
copy() {
this.$Clipboard({
text: '测试==复制至剪切板的文本==测试'
}).then(() => {
this.$message.success('复制成功')
}).catch(() => {
this.$message.error('复制失败')
});
}
}
}
</script>
参数 | 说明 | 类型 | 可选值 | 默认值 |
---|---|---|---|---|
text | 复制的文本 | String | - | - |
This app can be installed on your PC or mobile device. This will allow this web app to look and behave like any other installed app. You will find it in your app lists and be able to pin it to your home screen, start menus or task bars. This installed web app will also be able to safely interact with other apps and your operating system.