V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
YongAiFaDian
V2EX  ›  Vue.js

请教一个 vue2 浏览器兼容问题

  •  
  •   YongAiFaDian · May 9, 2023 · 2165 views
    This topic created in 1084 days ago, the information mentioned may be changed or developed.

    小弟目前使用的版本是 vue 2 + webpack 4 (比较落后的一个配置方案)

    现在遇到了一个问题: 当 "browserslist": [ "> 1%", "last 2 versions" ] 时,引入的一个包会发生报错

    当设置为

    "browserslist": [ "defaults and supports es6-module", "maintained node versions" ],

    时,报错解决,但是 asyn.queue 等等的 callback 没了,看官方文档说可以不需要,但是我们的业务系统使用了大量的 callback ,所以改起来很麻烦。 求问大神如何做到兼容方案

    3 replies    2023-05-11 11:40:16 +08:00
    karott7
        1
    karott7  
       May 9, 2023
    给的信息不够多
    1. 先把 “当 "browserslist": [ "> 1%", "last 2 versions" ] 时,引入的一个包会发生报错” 的报错贴一下
    2. 你这是个 node 项目吧,asyn.queue 是不是打错了?是 async.queue ? 看了下当前 lts node 版本没搜到 async.queue
    YongAiFaDian
        2
    YongAiFaDian  
    OP
       May 9, 2023
    @karott7
    1 的错误是:
    TypeError: Cannot convert a BigInt value to a number
    at Math.pow (<anonymous>)
    at SWUFpSqrtRatio (weierstrass.ts:1097:1)
    at mapToCurveSimpleSWU (weierstrass.ts:1166:1)
    at eval (secp256k1.ts:249:1)
    at ./node_modules/_@[email protected]@@noble/curves/secp256k1.js (chunk-vendors.js:15341:1)
    at __webpack_require__ (app.js:854:30)

    2.对 是 async.queue mapLimit 等
    karott7
        3
    karott7  
       May 11, 2023
    @YongAiFaDian
    1. 第一个问题看报错是 Math.pow 方法混用了 BigInt 类型和 number 类型,参考 https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Cant_convert_BigInt_to_number , 改成同类型应该就能解决了
    2. 搜了下,官方没有 async.queue 方法,然后在 npm 里搜到了 async 包,你可以下载试试,有 async.queue 和 async. mapLimit 方法,你的项目应该是用了这个包
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3384 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 12:53 · PVG 20:53 · LAX 05:53 · JFK 08:53
    ♥ Do have faith in what you're doing.