jsx2json
jsx-to-json-brick
parses JSX into usable JSON.
install
npm install jsx-to-json-brick
使用
const jsx2json = ;const result = //Result type : 'button' props : disabled : true children : type: 'text' text: 'Hello{this.a()}'
使用评估
如果您想解析基于javascript的参数,则可以使用该useEval选项。注意:eval如果您不控制输入,不仅使用危险,而且的结果jsx2json可能不是纯JSON。
; //Result type : 'button' props : { } style : top : '4px' color : 'white' children :
复杂的用例
const result = ;
结果
type: 'Nav.Item' props : className : 'test' children : 'Hello' type : 'a' props : href : '/test' children : type: 'text' text: 'you' type : 'button' props : disabled : true {} children : type: 'text' text: 'Press me'