美文网首页
eslintrc模式下如何使用未定义的变量

eslintrc模式下如何使用未定义的变量

作者: 前端划水工 | 来源:发表于2018-06-28 14:55 被阅读0次

    公司在做积分兑换时需要引入网易云盾的安全验证
    在vue的mounted周期内添加

    initNECaptcha({
            captchaId: '***********************',
            element: '#captcha_div',
            mode: 'embed',
            width: '320px',
            onVerify: function (err, ret) {
              if (!err) {
                // success
              }
            }.bind(this)
          }, function onload (instance) {
            this.codeInstance = instance
            //this.codeInstance.refresh()刷新验证码
            // this.codeInstance.popUp();
            // 初始化成功后得到验证实例instance,可以调用实例的方法
          }.bind(this), function onerror (err) {
            console.log(err)
            // 初始化失败后触发该函数,err对象描述当前错误信息
          })
    

    但是因为eslintrc检测到initNECaptcha并未被定义,所以会导致编译不同通过
    不用着急,我们只需在项目根目录找到.eslintrc文件
    在globals添加一下就好

    "globals": {
        "initNECaptcha": true
      }
    

    相关文章

      网友评论

          本文标题:eslintrc模式下如何使用未定义的变量

          本文链接:https://www.haomeiwen.com/subject/divgyftx.html