iugo
V2EX  ›  问与答

Babel 有没有注释语法可以让某代码块跳过转码?

  •  
  •   iugo · Aug 30, 2017 · 1436 views
    This topic created in 3187 days ago, the information mentioned may be changed or developed.

    比如

    /* nobabel begin */
    class MyError extends Error {
    }
    /* nobabel end */
    

    在自定义错误的时候, 找不到比在浏览器中直接扩展错误类更好的办法了. (参考过 https://stackoverflow.com/questions/1382107/whats-a-good-way-to-extend-error-in-javascript )

    目前是将不需要 Babel 的内容放在一起加入 ignore. 也能迂回解决.

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3220 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 41ms · UTC 03:26 · PVG 11:26 · LAX 20:26 · JFK 23:26
    ♥ Do have faith in what you're doing.