https://github.com/andrei-markeev/vue2jsx
Small utility for converting Vue templates to jsx.
https://github.com/andrei-markeev/vue2jsx
Last synced: 12 months ago
JSON representation
Small utility for converting Vue templates to jsx.
- Host: GitHub
- URL: https://github.com/andrei-markeev/vue2jsx
- Owner: andrei-markeev
- Created: 2018-07-01T02:24:42.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-08-19T23:31:56.000Z (almost 8 years ago)
- Last Synced: 2025-05-15T06:42:19.989Z (about 1 year ago)
- Language: TypeScript
- Size: 9.77 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# vue2jsx
Convert Vue html templates to their JSX representation.
Usage:
```
npm i -g vue2jsx
vue2jsx my-component.vue > my-component.tsx
```
**Note**: some post-processing is usually necessary after the conversion.
## Example
The following Vue SFC:
```html
export default {
data() {
return {
user: null,
users: null
}
}
}
Hello, {{user.name}}!
Hello to all of you:
- u.name
!
Hello, anonymous!
h1 { color: green }
```
results in this output:
```jsx
const render = function(h) { return (
{ this.user ? Hello, { this.user.name }!
: this.users ?
Hello to all of you:
{ this.users.map(u => - u.name
) }!
: Hello, anonymous!
}
}
```