今晚在使用Vue3开发的时候报了以下错误:
‘defineExpose’ is not defined
‘defineProps’ is not defined
‘defineEmits’ is not defined no-undef
‘withDefaults’ is not defined no-undef
在这里插入图片描述
百度了一下发现有人说在eslint的规则里加

 rules: {
    "no-undef": "off"
  },

但这个规则把所有未定义的变量的错误都屏蔽了,不是最优的解决方案,最后查了官网,发现官网建议这样:
"vue/setup-compiler-macros": true
但加**“vue/setup-compiler-macros”: true** 之后又报了另外一个错误:在这里插入图片描述

最终发现是eslint和eslint-plugin-vue的版本问题
最后我把版本更新为

yarn add eslint@7.32.0
yarn add eslint-plugin-vue@8.0.0

就完美解决了

Logo

基于 Vue 的企业级 UI 组件库和中后台系统解决方案,为数万开发者服务。

更多推荐