An open API service indexing awesome lists of open source software.

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.

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!

}

}
```