[英]TinyMCE getContent Returns Null
我正在嘗試從 TinyMCE 編輯器中獲取原始 HTML。 這是我正在使用的代碼
tinymce.init({
selector: 'textarea',
plugins: 'a11ychecker advcode casechange export formatpainter image editimage linkchecker autolink lists checklist media mediaembed pageembed permanentpen powerpaste table advtable tableofcontents tinycomments tinymcespellchecker',
toolbar: 'a11ycheck addcomment showcomments casechange checklist code export formatpainter image editimage pageembed permanentpen table tableofcontents',
toolbar_mode: 'floating',
tinycomments_mode: 'embedded',
tinycomments_author: 'Author name',
});
console.log (tinymce.get('content-text'))
在控制台中它顯示為空。 我還使用了活動編輯器功能。
console.log (tinymce.activeEditor.getContent())
這樣做會給我一個錯誤
Uncaught TypeError: Cannot read properties of null (reading 'getContent')
at contact-us.html:62:43
我正在使用 TinyMCE 6.1 版
將<script>
放在<textarea>
下方,然后重試。
或者嘗試將 ID 添加到textarea
標簽上,例如
<textarea id="tinyarea">
...
</textarea>
並將js中的選擇器更改為
selector: 'textarea#tinyarea',
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.