Created
July 29, 2019 02:53
-
-
Save rayshih/15a11388dd747821ed184ad9e77ce261 to your computer and use it in GitHub Desktop.
demo of babel plugin vue-react
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rayshih-mbp:vue-react rayshih$ cat test.jsx | |
export default () => { | |
const items = [1, 2, 3]; | |
return ( | |
<ul> | |
<li v-for="item in items"> | |
There is something todo with {item} | |
</li> | |
</ul> | |
); | |
} | |
rayshih-mbp:vue-react rayshih$ node index.js | |
---result code--- | |
export default (() => { | |
const items = [1, 2, 3]; | |
return React.createElement("ul", null, items.map(item => React.createElement("li", null, "There is something todo wi | |
th ", item))); | |
}); | |
rayshih-mbp:vue-react rayshih$ cat target.jsx | |
export default () => { | |
const items = [1, 2, 3]; | |
return ( | |
<ul> | |
{items.map(item => ( | |
<li> | |
There is something todo with {item} | |
</li> | |
))} | |
</ul> | |
); | |
} | |
rayshih-mbp:vue-react rayshih$ cat target.js | |
---result code--- | |
export default (() => { | |
const items = [1, 2, 3]; | |
return React.createElement( | |
"ul", null, | |
items.map(item => React.createElement("li", null, | |
"There is something todo with ", item) | |
) | |
); | |
}); | |
rayshih-mbp:vue-react rayshih$ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment