我必须使用 javascript 库 (emailJS) 从我的 vuejs 应用程序发送电子邮件。问题是这个库创建了一个全局函数,当我尝试使用这个函数时,eslint 通知我这个函数没有定义。
是否可以将此功能包装到 javascript 模块中以在组件上使用?
最佳答案
有时根本无法避免全局变量(我在看着你,gapi
)。只需将它添加到您的 eslint globals
配置中即可。
在.eslintrc.js
module.exports = {
// ...
globals: {
SmtpClient: true // or whatever the global variable is named
}
}
参见 http://eslint.org/docs/user-guide/configuring#specifying-globals
关于javascript - 在 vuejs 中使用全局函数。 Lint (?),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45683146/