Tencent / Tencent/cherry-markdown
[Bug Report] 调用cherryInstance.setValue方法的时候,进入页面出现异常
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 4.9k
- Forks
- 572
- Avg merge
- 17h 5m
- Merged PRs (30d)
- 14
Description
Prerequisites
- There isn't an existing issue that reports the same bug to avoid duplicates.
- The provided information offers a minimal reproducible example of the bug.
- For Q&A, please open a GitHub Discussion instead.
Describe the Bug
我想实现编辑文章的功能,点击编辑的时候会跳转到编辑页面,显示文章信息,编辑页面采用的是cherry这个
最开始的调用如下: 用的是ref
<div>
<!-- 编辑器-->
<cherry-components ref="cherryComponents"
:height="height"
:editorModel="editorModel"
></cherry-components>
</div>
this.$refs.cherryComponents.cherryInstance.setValue('');
看到有老哥说是ref的问题,然后我就用数据总线mitt,结果还是不行
A:
EventBus.emit("set-content", res.data.data.content);
B:
mounted() {
this.initMarkDown();
EventBus.on("set-content", (content) => {
this.content = content;
this.cherryInstance.setValue(content);
});
},
这样还是会有问题,是我的调用方法不对吗
项目参考:https://gitee.com/HelloWangXianLin/xiaoxiao-demo/tree/master/SpringBoot+Layui+Vue%20%E7%BC%96%E8%BE%91%E5%99%A8/easy-editor-ui
Reproduction Steps
No response
System Information
No response
Contributing
None
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The report mentions the cherry-components ref, cherryInstance.setValue, and an EventBus listener, with a linked demo project. Start by comparing the demo's editor initialization and setValue timing with the reported Vue usage. Done means reproducing the page-entry exception and documenting a confirmed cause or a clearly scoped fix.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100