React-sugar
在react里提供 v-for、v-model、v-if、 自动绑定key 的语法糖。
Usage
install
npm i babel-plugin-react-sugar --save-dev
.babelrc
update "plugins": "react-sugar" // options
Example
v-model
{ ; thisstate = value: '' ; } { return <div> <p>thisstatevalue</p> <input = /> </div> ; }
bindAttrName
"plugins": "react-sugar" // v-model bindAttrName: 'r-model'
//... { return <div> <p>thisstatevalue</p> <input = /> </div> ;}
v-for
{ ; thisstate = items: message: 'Foo' message: 'Bar' ; } { return <ul> <li => <p>itemmessage</p> <p>itemmessage ? 'true' : 'false'</p> </li> </ul> ; }
loopAttrName
"plugins": "react-sugar" // v-for loopAttrName: 'r-for'
v-if
{ ; thisstate = onShow: true ; } { return <div> <Self = /> </div> ; } { return <span>1</span> <span>2</span>; }
ifAttrName
"plugins": "react-sugar" // v-if ifAttrName: 'r-if'
Contributing
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
yarn run commit
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
Author
react-sugar © zero1five, Released under the MIT License.
Authored and maintained by zero1five.
github.com/zero1five · GitHub @zero1five · Twitter @zero1five
License
MIT © zero1five