各位好今天遇到了个问题
有一个外部元件叫做<<>TextEditor>
他当中是这样的结构
<div
placeholder="请填写"
contenteditable="true"
class="w-100 text-editor border border-gray300 bg-white rounded-lg p-3 text-break overflow-y outline-0 border-light"
style="height: calc(100% - 1em);">
</div>
今天的我在外部使用此元件想做到只能输入纯文本(也就是contenteditable:"plaintext-only")的效果
试了版上很多方法都没有作用
想请问有怎样的方法能够实现
感谢
参考GPT和自己的思路:
您可以在使用<<>TextEditor>元件的地方,使用修改器将contenteditable属性设置为"plaintext-only",即可实现只能输入纯文本的效果。例如:
<<>TextEditor :contenteditable="'plaintext-only'" />
或者在<<>TextEditor>自身的代码中,将contenteditable属性设置为"plaintext-only"。例如:
<div
placeholder="请填写"
contenteditable="plaintext-only"
class="w-100 text-editor border border-gray300 bg-white rounded-lg p-3 text-break overflow-y outline-0 border-light"
style="height: calc(100% - 1em);">
</div>
这样就能够实现只能输入纯文本的效果了。希望对您有所帮助。