当前第2页 返回上一页
里面还有很多高级用法,可以前往官网逻辑更多细节 Clipboard官网
4. Vue框架提供的剪切板插件 vue-clipboard2
1 2 3 4 5 | import Vue from 'vue'
import VueClipboard from 'vue-clipboard2'
VueClipboard.config.autoSetContainer = true
Vue.use(VueClipboard)
|
Sample1
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 | <p id= "app" ></p>
<template id= "t" >
<p class= "container" >
<input type= "text" v-model= "message" >
<button type= "button"
v-clipboard:copy= "message"
v-clipboard:success= "onCopy"
v-clipboard:error= "onError" >Copy!</button>
</p>
</template>
<script>
new Vue({
el: '#app' ,
template: '#t' ,
data: function () {
return {
message: 'Copy These Text'
}
},
methods: {
onCopy: function (e) {
alert( 'You just copied: ' + e.text)
},
onError: function (e) {
alert( 'Failed to copy texts' )
}
}
})
</script>
|
Sample2
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 | <p id= "app" ></p>
<template id= "t" >
<p class= "container" >
<input type= "text" v-model= "message" >
<button type= "button" @click= "doCopy" >Copy!</button>
</p>
</template>
<script>
new Vue({
el: '#app' ,
template: '#t' ,
data: function () {
return {
message: 'Copy These Text'
}
},
methods: {
doCopy: function () {
this .$copyText( this .message).then( function (e) {
alert( 'Copied' )
console.log(e)
}, function (e) {
alert( 'Can not copy' )
console.log(e)
})
}
}
})
</script>
|
以上就是本文的全部内容,希望对大家的学习有所帮助,更多相关内容请关注PHP中文网!
相关推荐:
如何通过HTML5触摸事件实现移动端简易进度条
Html5移动端获奖无缝滚动动画实现
html5 touch事件实现触屏页面上下滑动
以上就是Html5剪切板功能的实现的详细内容,更多文章请关注木庄网络博客!
返回前面的内容
相关阅读 >>
HTML5本地存储-web sql database的详情介绍
html4与HTML5的区别有哪些
HTML5中设置或返回音频/视频是否应该被静音的属性muted
HTML5是什么技术
HTML5的本地存储indexeddb
h5的拖放应该如何实现
前端必看h5 meta小结
HTML5游戏框架cngamejs开发实录-碰撞检测模块篇
震惊!HTML5区块链游戏联盟成立,设立10亿级发展基金!
h5表单验证有哪些方法
更多相关阅读请进入《HTML5》频道 >>
人民邮电出版社
本书对 Vue.js 3 技术细节的分析非常可靠,对于需要深入理解 Vue.js 3 的用户会有很大的帮助。——尤雨溪,Vue.js作者
转载请注明出处:木庄网络博客 » Html5剪切板功能的实现