项目场景:
vue3+vite项目中报错Cannot read properties of null (reading ‘insertBefore‘)
原因分析:
:v-自定义权限指令与v-if互相影响
<el-button text bg type="primary" @click="handleWrite(detailData,'项目填报')" v-hasPermi="['manager:write']"v-if="detailData.status!='已完工'">项目填报
</el-button>
解决方案:
v-if换成v-show,或者自定义指令里面更换成el.style.display = “none”,或者弃用自定义指令,把权限加在v-if中一并判断。
这里根据poe中Claude的回答进行了调整
这里采用了方案1,修改如下,完美解决问题。
<el-button text bg type="primary" @click="handleWrite(detailData,'项目填报')" v-hasPermi="['manager:write']"v-if="detailData && detailData.status && detailData.status!='已完工'">项目填报
</el-button>