Missing radix parameter 錯誤的解決辦法


下載了Mint-Ui的example,使用npm run dev時發現如下報錯:

ERROR in ./packages/loadmore/src/loadmore.vue

  ✘  http://eslint.org/docs/rules/radix  Missing radix parameter  
  D:\WebStormProject\mint-ui-master\packages\loadmore\src\loadmore.vue:271:18
          return parseInt(this.$el.getBoundingClientRect().bottom) <= parseInt(this.scrollEventTarget.getBoundingClientRect().bottom) + 1;
  ✘  http://eslint.org/docs/rules/radix  Missing radix parameter  
  D:\WebStormProject\mint-ui-master\packages\loadmore\src\loadmore.vue:271:71
          return parseInt(this.$el.getBoundingClientRect().bottom) <= parseInt(this.scrollEventTarget.getBoundingClientRect().bottom) + 1;
                                                                         
✘ 2 problems (2 errors, 0 warnings)
Errors:
  2  http://eslint.org/docs/rules/radix
按錯誤提示找到./packages/loadmore/src/loadmore.vue 文件
發現文件中以下代碼有提示報錯
      checkBottomReached() {
        if (this.scrollEventTarget === window) {
          /**
           * fix:scrollTop===0
           */
          return document.documentElement.scrollTop || document.body.scrollTop + document.documentElement.clientHeight >= document.body.scrollHeight;
        } else {
          return parseInt(this.$el.getBoundingClientRect().bottom) <= parseInt(this.scrollEventTarget.getBoundingClientRect().bottom) + 1;  ///提示有錯
        }
      },
 
        

一番搜索后,發現Missing radix parameter的意思是:缺少一個基數根,也就是指:parseint的第二個參數沒有指定。

這是因使用ESLint檢查javascript代碼語法時壓縮工具對語法的嚴謹性要求比較高。

雖然parseInt的第二個參數默認是十進制,(第二參數有四種:2、8、10、16,分別對應二進制、八進制、十進制、十六進制);
但在parseInt語法進行轉換時,還是要求明確加個第二個參數.

代碼改為以下即可

 return parseInt(this.$el.getBoundingClientRect().bottom,10) <= parseInt(this.scrollEventTarget.getBoundingClientRect().bottom,10) + 1;  

 

 
       


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM