小程序,vue,react写法区分

 1. 标签内属性:

  vue:  :key = "index"   (直接字符串)

react: key={index}   (单括号)

小程序: key="{{index}}"   (字符串内双括号)

2.绑定事件

vue:  @click="clickFuc"  (字符串)

react: onClick={clickFuc}  (单括号)

小程序: onTap=“clickFuc”  (字符串)

3.动态内联style和class

vue:

    :style="{height: xx > 0? '300px' : ' ' }"

     :class="{firstImg: index === 0}"    

react:

   style={{display: (index === this.state.currentIndex) ? 'block': 'none'}}

   className={`red ${index === this.state.currentIndex ?'active' : null }`}

小程序:  

  

   style="display:  {{ num ===3? 'block' :  'none' }}"

   class="red {{num==3?'cur':' '}}"

猜你喜欢

转载自blog.csdn.net/bangbDIV/article/details/83069353