Skip to content

Instantly share code, notes, and snippets.

@rayshih
Created July 29, 2019 02:53
Show Gist options
  • Save rayshih/15a11388dd747821ed184ad9e77ce261 to your computer and use it in GitHub Desktop.
Save rayshih/15a11388dd747821ed184ad9e77ce261 to your computer and use it in GitHub Desktop.
demo of babel plugin vue-react
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