Vue3报错: ‘defineProps‘ is not defined,解决方法

2023-12-15 12:58:21

问题出现:

今天在使用 <script setup>组合式 API 的语法糖的时候,定义defineProps时候报错:
在这里插入图片描述
‘defineProps’ is not defined
查了一下资料,这是因为eslint的语法校验导致的问题。

解决方法1:

在项目根目录的文件.eslintrc.js中做如下配置:
添加配置:"vue/setup-compiler-macros": true,配置完之后需要重启项目,即可解决。

解决方法2:

如果你的项目根目录下没有.eslintrc.js文件,那就找到package.json文件
找到eslintConfig配置项,在这里配置规则:"vue/setup-compiler-macros": true
在这里插入图片描述

在这里插入图片描述

文章来源:https://blog.csdn.net/m0_48300767/article/details/135012678
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。