微信小程序Eslint配置中需添加全局方法

分类:技术来源:bobo最近更新:2026-04-11浏览:2394

微信小程序中有很多全局的方法,在用eslint的时候如果不添加好,会报错

在.eslintrc.js添加全局方法如下:

globals: {
wx: true,
App: true,
Page: true,
Component: true,
getApp: true,
getCurrentPages: true,
Behavior: true,
global: true,
__wxConfig: true,
},

特别注意,微信开发者工具和VScode工具一样,需要安装eslint插件,eslint才生效,如下图

blogfile/editor/202211/1669813140680529452.png

上一篇:ChatGPT和AIGC的区别

没有下一篇