Tencent / Tencent/cherry-markdown

[Bug Report] 调用cherryInstance.setValue方法的时候,进入页面出现异常

Open
#753 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

🐞bug
Dominant language
JavaScript
Stars
4.9k
Forks
572
Avg merge
17h 5m
Merged PRs (30d)
14

Description

Prerequisites
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.