vue 复制功能


npm install --save vue-clipboard2


import Vue from 'vue'
import VueClipboard from 'vue-clipboard2'

Vue.use(VueClipboard)

 

 


Sample:

<div id="app"></div>
<template id="t">
<div 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>
</div>
</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)
},
one rror: function (e) {
alert('Failed to copy texts')
}
}
})

上一篇:gvim命令与快捷键


下一篇:小体积大能量-物联网开发板LinkIt Smart 7688