通过在线babel转换器,转换出jsx是如何变成js对象的
jsx文件
加入了正常的标签以及嵌套标签以及方法属性
function hello() { click=()=>{ console.log("hello") } return <div> <button onclick={this.click.bind(this)}> helloWorld </button> </div>; }
通过babel转换之后
"use strict"; function hello() { click = function click() { console.log("hello"); }; return React.createElement("div", null, React.createElement("button", { onclick: this.click.bind(this) }, "helloWorld")); }
在线babel编辑器 测试
本文详细解析了如何使用Babel将JSX语法转换为标准的JavaScript对象,具体展示了从带有事件处理和嵌套标签的JSX代码到React.createElement调用的转换过程。

被折叠的 条评论
为什么被折叠?



