vue3+elementPlus遇到坑以及解决方法

2,640 阅读1分钟

1. TypeError: Cannot read properties of null (reading 'insertBefore')

image.png

image.png

image.png

解决方法:

  1. v-if修改为:v-show

  2. el-table-column 渲染时报错,#default="{ row }" ,row中的值没有拿到,使用row.name && row.name

2. elementPlus autocomplete 自动补全输入框

问题描述:搜索到结果,点击回车,出现警告。

image.png

解决办法:添加value-key属性,你返回的对象没有value导致

 <el-autocomplete v-model="state2" value-key="name"/>

后台返回结果参数:

const result = [
  { name: vue, id: 1 },
  { name: react, id: 2 },
]

3. elementPlus elTooltip

问题描述:element-plus.js?v=38852860:9576 ElementPlusError: [ElOnlyChild] no valid child node found

解决办法:可能缺少子元素,添加即可

<el-tooltip placement="top" effect="light">
    <template #content>
      <span>提示</span>
    </template>
    // 可能缺少子元素
    <!-- <span>123</span> -->
</el-tooltip>

持续更新中....