小程序 vue react区别
本文总结了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':' '}}"
4. 数据修改
Vue
this.data1 = 123;
来源gaodai.ma#com搞#代!码网
React
this.setState({ data1: 123 });
小程序
this.setData({ data1: 123 });
本文来自React答疑栏目,欢迎学习!
以上就是小程序 vue react区别的详细内容,更多请关注gaodaima搞代码网其它相关文章!