使用nextTick 来在文档加载完成后渲染summernote
getMessageDetail() {
this.$http
.get(this.API.MESSAGE_DETAIL + this.$route.params.messageId)
.then(response => {
this.addParams = response.data;
if (this.addParams.action === "1") {
this.$nextTick(() => {
$(this.$refs.contentNote).summernote({
minHeight: 200,
lang: "zh-CN"
});
$(this.$refs.contentNote).summernote(
"code",
this.addParams.content
);
});
}
});
},
actionChange() {
console.log("aaaaaaaaaaaaaaaaaaaaaaaa" + this.addParams.action);
if (this.addParams.action === "1") {
this.$nextTick(() => {
$(this.$refs.contentNote).summernote({
minHeight: 200,
lang: "zh-CN"
});
$(this.$refs.contentNote).summernote("code", this.addParams.content);
});
} else {
$(this.$refs.contentNote).summernote("destroy");
}
}
或者删除
summernote 自动调用destory
actionChange() {
console.log("aaaaaaaaaaaaaaaaaaaaaaaa" + this.addParams.action);
if (this.addParams.action === "1") {
this.$nextTick(() => {
$(this.$refs.contentNote).summernote({
minHeight: 200,
lang: "zh-CN"
});
$(this.$refs.contentNote).summernote("code", this.addParams.content);
});
} else {
$(this.$refs.contentNote).summernote("destroy");
}
}