React常见问题解决
本文是基于Windows 10系统环境,学习和使用React:
- Windows 10
一、react常见问题解决方案
(1) 拼接字符串(常量+变量)
const variable = 'department'
const param1 = 'inspur'
const param2 = 'chaoyue'
<a href={'https://wap.inspur.com/' + variable}>
${param1}--${param2}
</a>
//inspur--chaoyue
<FormItem label={formatMessage({ id: 'app.mail.read' })}>
{getFieldDecorator('senderInfo', {
initialValue: `${sender}--${time}`
}
)(
<Input readOnly />
)}
</FormItem>
(2) 阻止默认事件和冒泡
handleCheck = (e, item) => {
e.stopPropagation();
console.log('handleCheck');
console.log(item);
}
(3) 设置启动的端口号
## 打开react项目的 package.json文件
## 将 scripts中的start键值对
"start": "react-app-rewired start"
## 修改为
"start": "set PORT=3008&&react-app-rewired start",
(4) 输出<,<=,>,>=
<span>></span> # >
<span>&ge</span> # >=
<span><</span> # <
<span>&le</span> # <=
(5) 合并两个列表
let a = [1, 2, 3];
let b = [4, 5, 6];
let c = a.concat(b);
console.log(c); // c= [1, 2, 3, 4, 5, 6]
二、ant design常见问题解决方案
(1) 设置Select下拉框的显示层级
<Select dropdownStyle={{ zIndex: 10001 }}>
<Option value='chaoyue'>浪潮超越</Option>
</Select>