vue 如何实现复制到粘帖板
A simple vuejs 2 binding for clipboard.js
Install
npm
install --save vue-clipboard2 or use dist/vue-clipboard.min.js without
webpack
Usage
For vue-cli user:
import Vueimport VueClipboard from "vue-clipboard2" Vue.use(VueClipboard)For standalone usage:
<script src="vue.min.js"></script><!-- must place this line after vue.js --><script src="dist/vue-clipboard.min.js"></script>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) }, onError: function (e) { alert("Failed to copy texts") } }})</script>声明:该文观点仅代表作者本人,入门客AI创业平台信息发布平台仅提供信息存储空间服务,如有疑问请联系rumenke@qq.com。
- 上一篇:没有了
- 下一篇:没有了
