
react
koga007
这个作者很懒,什么都没留下…
展开
-
react动态添加class
1.动态的添加class 当前元素上没有其他的class <div class={'className'}></div> 当前元素上本身有其他的class,又要动态的添加class时: <div class={['className1',index==0?'className2':null].join(' ')}></div> 或者使用...原创 2018-08-14 15:04:45 · 10067 阅读 · 1 评论 -
react事件处理,为类方法绑定this
react事件绑定属性的命名采用驼峰命名法, 如果采用JSX的语法,需要传入一个函数作为事件处理函数,而不是一个字符串(DOM元素的写法)。 阻止事件的默认行为: 不能使用返回false的方式来阻止默认行为,必须明确的使用preventDefault 在类方法中绑定this 注:要谨慎的在类方法中使用this,因为类方法默认不会绑定this。需要主动的将这类方法绑定到this上。 为类方法...原创 2018-08-15 15:02:57 · 438 阅读 · 0 评论 -
create-react-app 使用详解
快速开始 npm install -g create-react-app create-react-app my-app cd my-app/ npm start 通过http://localhost:3000/查看你的app 使用 npm run build 编译打包程序 npm test 文件修改后测试,这部分内容后面讲 更新到最新版本 创建react app的主要分...转载 2019-06-11 10:29:26 · 438 阅读 · 0 评论