Vue jsx User Guide and vue. js method using jsx syntax, vue. jsjsx

Source: Internet
Author: User

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!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.