fix:Editor 开启、禁用不生效的问题

This commit is contained in:
YunaiV
2025-12-26 21:08:40 +08:00
parent 1b85de732b
commit 94ae3bb48a
2 changed files with 8 additions and 4 deletions

View File

@@ -8,6 +8,7 @@ import { ElMessage } from 'element-plus'
import { useLocaleStore } from '@/store/modules/locale'
import { getRefreshToken, getTenantId } from '@/utils/auth'
import { getUploadUrl } from '@/components/UploadFile/src/useUpload'
import merge from 'lodash-es/merge'
defineOptions({ name: 'Editor' })
@@ -60,7 +61,11 @@ watch(
)
watch(
() => props.readonly,
(val) => {
async (val) => {
// 特殊:等待 editorRef 渲染完成
if (!editorRef.value) {
await nextTick()
}
if (val) {
editorRef.value?.disable()
} else {
@@ -75,7 +80,7 @@ const handleCreated = (editor: IDomEditor) => {
// 编辑器配置
const editorConfig = computed((): IEditorConfig => {
return Object.assign(
return merge(
{
placeholder: '请输入内容...',
readOnly: props.readonly,

View File

@@ -3,8 +3,7 @@
<el-form ref="formRef" :model="formData" :rules="rules" label-width="120px" :disabled="isDetail">
<!--富文本编辑器组件-->
<el-form-item label="商品详情" prop="description">
<Editor v-if="!isDetail" v-model:modelValue="formData.description" />
<Editor v-else :modelValue="formData.description" readonly />
<Editor :readonly="isDetail" v-model:modelValue="formData.description" />
</el-form-item>
</el-form>
</template>