Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 修复富文本编辑器初始化时, 报错 Error: Cannot find a descendant at path [0,1] i… #472

Merged
merged 1 commit into from
May 24, 2024

Conversation

clddup
Copy link
Contributor

@clddup clddup commented May 24, 2024

No description provided.

@clddup
Copy link
Contributor Author

clddup commented May 24, 2024

富文本html.txt

当html内容为上面文件里的内容时, 会报错

image

排查发现在组件 watch 配置 immediate: true时 刚进来就给 valueHtml 赋值上面文本内容会报错

watch(
  () => props.modelValue,
  (val: string) => {
    if (val === unref(valueHtml)) return
    valueHtml.value = val 
  },
  {
    immediate: true
  }
)

解决办法: 应该将 valueHtml 初始化赋值放到 handleCreated 函数中, 并将 immediate去掉

watch(
  () => props.modelValue,
  (val: string) => {
    if (val === unref(valueHtml)) return
    valueHtml.value = val 
  }
)
```js
const handleCreated = (editor: IDomEditor) => {
  editorRef.value = editor
  valueHtml.value = props.modelValue
}

@kailong321200875 kailong321200875 merged commit 138ffba into kailong321200875:master May 24, 2024
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants