如何使用VueJs在插入符位置/选择上粘贴文本?

问题描述

如何使用VueJs在光标位置/选择上插入文本?

我处理“粘贴”事件以清除粘贴的内容(仅适用于纯文本),但是我找不到如何插入内容方法

<div id="app">
  <div contenteditable
       v-on:paste.prevent="onPaste"
  >
    Paste your text here
  </div>
</div>

<script>
new Vue({
  el: "#app",methods: {
    onPaste(evt) {
      const text = evt.clipboardData.getData('text/plain');
      alert(text);
      // How insert text on the caret position or selection?
    },}
});
</script>

https://jsfiddle.net/mhs170po/

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)