• 请不要在回答技术问题时复制粘贴 AI 生成的内容
hu1e
V2EX  ›  程序员

vitejs/plugin-legacy 这个插件是怎么做到兼容 chorme < 60, firefox < 59 的?

  •  
  •   hu1e · Mar 22, 2024 · 1624 views
    This topic created in 814 days ago, the information mentioned may be changed or developed.
    // legacy 可以支持通过配置下列配置去兼容传统浏览器
    legacy({
        targets: ['chrome < 60', 'edge < 15', 'firefox <= 52'],
    })
    

    据我所知,plugin-legacy 是通过利用 script nomodule 去加入兼容性代码,但是 script nomodule 不支持 chrome < 60 、firefox < 59 ,所以这是怎么办到的?直接判断版本强行插入普通 script 去执行兼容性代码么?

    2 replies    2024-03-22 16:43:43 +08:00
    codehz
        1
    codehz  
       Mar 22, 2024   ❤️ 2
    nomodule 的兼容性是指:支持 nomodule 的浏览器就不去加载这个 script
    不支持 nomodule 的就会自动加载(因为不认识的 attribute 被忽略)
    hu1e
        2
    hu1e  
    OP
       Mar 22, 2024
    @codehz 原来是这样,感谢
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2533 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 35ms · UTC 15:50 · PVG 23:50 · LAX 08:50 · JFK 11:50
    ♥ Do have faith in what you're doing.