【问题标题】:Using global function in vuejs. linter (?)在 vuejs 中使用全局函数。短绒(?)
【发布时间】:2018-01-22 19:14:12
【问题描述】:

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

是否可以将此功能包装到 javascript 模块中以在组件上使用?

【问题讨论】:

    标签: javascript vuejs2 eslint


    【解决方案1】:

    有时无法避免全局变量(我在看着你,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

    【讨论】:

      猜你喜欢
      • 2019-07-31
      • 1970-01-01
      • 2019-04-24
      • 2017-08-25
      • 2022-07-22
      • 2020-04-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多