Inndy / vue-clipboard2

A simple vue2 binding to clipboard.js

Home Page:https://vue-clipboard2.inndy.tw/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

What if i need to use Clipboard in bootstrap modal and in usuall place?

moneyinvest opened this issue · comments

I cant make it working in both places using container option. What to do?

I used in modal this code
this.$copyText(text, this.$refs.container), container is ref to our button copy.
it works

commented

Minimal reproduction sample please

As stated by @moneyinvest you can solve this problem by using this.$copyText and passing the ref of a container that your element with v-clipboard is in.

Alternatively you can use VueClipboard.config.autoSetContainer = true in your main.js and the directive will work.

@Inndy Reproduction Sample with both solutions
https://codesandbox.io/s/bootstrap-modal-vue-clipboard2-cx05k?file=/src/App.vue