在vuejs中使用全局函数。 linter(?)

问题描述:

我必须使用JavaScript库(emailJS)从我的vuejs应用程序发送电子邮件。问题是这个库创建一个全局函数,当我尝试使用该函数时,eslint通知我这个函数没有被定义。在vuejs中使用全局函数。 linter(?)

是否有可能将此函数包装到用于组件的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