博客做着做着感觉自己在囫囵吞,下来补充一下基本知识,从简单开始做起。
todolist基本练习demo,使用less和antd
github 的代码地址:https://github.com/3sang/react-practice-todolist
这是做完的界面:
还有自适应的部分。使用antd的栅栏布局做的
1.npm install -g create-react-app;
2.create-react-app my-app(my-app为项目名字);
1、先做出布局。
打算分成两个组件,list组件和父组件。
功能:
1、展示list
2、input添加list
3、删除List
4、对list打勾划线
使用antd:
yarn add antd 或者npm install antd --save
npm install @ant-design/icons
怎么用antd可以看这个https://www.cnblogs.com/orzzt/p/9719783.html
报错:
index.js:1 Warning: Failed prop type: You provided a checked
prop to a form field without an onChange
handler. This will render a read-only field. If the field should be mutable use defaultChecked
. Otherwise, set either onChange
or readOnly
.
原因是因为input标签,没有定义onChange 但是提供了value属性。React会抛出警告,并将元素设置为只读。
如果目标是只读字段,最好使用readOnly属性明确加以定义。这不仅会消除警告,也会确保代码的可读性。
antd水平垂直布局:
<Row type=“flex” justify=“center” align=“middle” style={{minHeight:‘100vh’}}>