Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.8k views
in Technique[技术] by (71.8m points)

有时候babel转换出来后还是有es6代码,为啥

如解构的,{a:1, b:1, ...c}
转出来后还是{a:1, b:1, ...c}


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
  1. babel 并不是要把 ES6 转成 ES5,而是把比较少支持的特性转换成更多支持的写法
  2. 这样一来,写代码的人可以用到最新最先进的写法,将来整个用户客户端升级了,也无需修改代码,修改 babel 配置即可
  3. 所以 babel 转换哪些代码是可以配置的,一般用 @babel/preset-env
  4. 所以你要先看自己的配置,如果有必要,也可以手动添加一些插件

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...