【发布时间】:2018-01-22 19:14:12
【问题描述】:
我必须使用 javascript 库 (emailJS) 从我的 vuejs 应用程序发送电子邮件。问题是这个库创建了一个全局函数,当我尝试使用该函数时,eslint 通知我这个函数没有定义。
是否可以将此功能包装到 javascript 模块中以在组件上使用?
【问题讨论】:
标签: javascript vuejs2 eslint
我必须使用 javascript 库 (emailJS) 从我的 vuejs 应用程序发送电子邮件。问题是这个库创建了一个全局函数,当我尝试使用该函数时,eslint 通知我这个函数没有定义。
是否可以将此功能包装到 javascript 模块中以在组件上使用?
【问题讨论】:
标签: javascript vuejs2 eslint
有时无法避免全局变量(我在看着你,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
【讨论】: