CKEditor不会显示我的文本区域值属性



我正在从一个数据库中检索文本,该数据库应该用作我的CKEditor字段的值。

这是我的代码:

<script src="https://cdn.ckeditor.com/ckeditor5/34.2.0/classic/ckeditor.js"></script>
<textarea id="editor" rows="6" name="post-body" value="<?php echo html_entity_decode($post['content']) ?>"></textarea>  
<script>
ClassicEditor
.create( document.querySelector( '#editor' ) )
.catch( error => {
console.error( error );
} );
</script>

但是,当呈现页面时,CKEditor字段为空;我的value属性的内容不会显示。

是什么原因造成的?我该怎么修?

Textarea没有属性value

内容介于<textarea></textarea>之间,或者如果要显示占位符,则必须使用属性placeholder

所以要么

<textarea id="editor" rows="6" name="post-body"><?php echo html_entity_decode($post['content']) ?></textarea> 

<textarea id="editor" rows="6" name="post-body" placeholder="<?php echo html_entity_decode($post['content']) ?>"></textarea> 

参见MDN 上的文本区域

参见价值属性

最新更新