【发布时间】:2019-03-03 10:13:39
【问题描述】:
我正在尝试让 Vuejs 和 TinyMCE 一起工作。 我使用 @tinymce/tinymce-vue 包,它是 TinyMCE 的 vue 集成。 我已按照所有说明进行操作,似乎一切正常,我的意思是我可以正确书写、插入图像……除了 v-model 部分之外的所有内容。
这是简化的模板:
<form action="/http://localhost:4000/articles" method="POST">
<input id="data_title" class="input-title" v-model="title" type="text"/>
<editor id="editor" v-model="content"></editor>
<textarea id="data_description" v-model="description" class="input-resume"></textarea>
</form>
脚本部分:
export default {
data() {
return {
title: "",
description: "",
content:"",
}
},
mounted() {
tinymce.init({
selector: '#editor',
plugins: "image",
toolbar: [
'undo redo | styleselect | bold italic | link image',
'alignleft aligncenter alignright'
]
});
}
我使用 axios 将数据发送到 Rest API:
axios.post('http://localhost:4000/articles', {
title: this.title,
description: this.description,
content: this.content,
})
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
});
},
一切正常,没有错误。发表文章后,我有标题和描述,但没有内容。 V-model 似乎不受<editor></editor> 的限制,因为在 chrome devtool 中,当我在其中编写时,什么都没有发生。表单中的其他 v-model 运行良好。
有什么想法吗?
感谢您的时间伙伴:)
【问题讨论】:
标签: javascript vue.js tinymce axios