Vue jsx User Guide and vue. js method using jsx syntax, vue. jsjsx
The vue jsx syntax is different from the react jsx syntax, which is recorded here.
Let component = null // if statement if (true) {component = (<div> </div> );} else {component = (<div> </div>);} var ul = (<ul> {component} </ul>); // map statement var coms = limit. map (I =>{ return {<li >{ ul} </li >};}) // attribute <li onClick = {() => console. log ()}> // custom command let ctives ves = [{name: 'prod-img ', value: params. row. skn, modifiers: {skn: true}]; return (<div> </img> // expand attributes </div> ); // Custom filters are not recommended. Use foo (something) directly when the function is used. // methodsthis. foo () // model <I-input value = {params. row. factoryCode} placeholder = 'enter... 'oninput = {val => (params. row. factoryCode = val)} style = {width: '000000' }></I-input> // return (<Operator category-id = {this. categoryId} // bind product = {params. row} // bind onChange = {this. onChangeStatus }>// event binding </Operator>); // triplicate <div>
Now let's take a look at how vue. js uses the jsx syntax.
1. Create a test component
export default { name:'Test', components:{ }, render(h){ return <div> test </div> }, data () { return { } }}
2. Set the js language version of the editor to jsx, so that the editor can correctly identify the jsx syntax.
3. Install npm Dependencies
babel-plugin-syntax-jsx\ babel-plugin-transform-vue-jsx\ babel-helper-vue-jsx-merge-props\
4. Modify. babelrc
{ "presets": ["es2015"], "plugins": ["transform-vue-jsx"]}
I downloaded the vux template. After modification, the jsx format files are successfully packaged.
Summary
The above section describes the vue jsx User Guide and the jsx syntax used by vue. js. I hope it will be helpful to you!