记录下react的坑
《一》windows dos设置代理
啥也不想说,焦点科技的网真是让我要吐了。
1.
1 2 3 4
| $ set http_proxy=http://192.168.16.232:8080 $ set https_proxy=http://192.168.16.232:8080 $ set http_proxy_user=username $ set http_proxy_pass=password
|
《二》npm的镜像替换成淘宝
- 设成淘宝的
1
| $ npm config set registry http://registry.npm.taobao.org/
|
2.换成原来的
1
| $ npm config set registry https://registry.npmjs.org/
|
《二》输入框自动联想
使用第三方控件:react-autocomplete
https://github.com/reactjs/react-autocomplete
例子:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| <Autocomplete getItemValue={(item) => item.label} items={this.state.autoCompleteItems} renderItem={(item, isHighlighted) => <div style={{ background: isHighlighted ? 'lightgray' : 'white'}}> {item.label} </div> } value={item_value[2]} wrapperStyle={{ position: 'relative', display: 'inline-block',zIndex:'99' }} onChange = {(e)=>this.getParmsValueInput(index,e)} onSelect={(e)=>this.getParmsValueSelect(index,e)} inputProps = {{ style:{width: 200,height:28,border:'1px solid #d9d9d9',borderRadius:4}}}
/>
|
如果是多个控件并存,使用zIndex控制层级:
《三》javascript replace用法
replace() 方法默认只会对匹配到的第一个字串替换。
要全部替换的话,使用正则表可以达成Replace 的效果。加上g:
1
| new_parms_edit_item[2] = key_input.target.value.replace(/,/g,'%2c')
|
《四》antd motion + dva 框架配置
dva新建了一个项目,把Antd motion的Home文件拖到项目中,各种报错,配置方面做个记录:
1
| location xxxxx no-restricted-globals
|
修改.eslintrc
1 2 3 4 5 6
| { "extends": "umi", "rules": { "no-restricted-globals": [0] } }
|
antd motion没有样式,虽然有修改说明,但不适用与DVA 2 ,应修改 .webpackrc 如下:
1 2 3 4 5
| { "disableCSSModules": true, "extraBabelPlugins": [ ["import", { "libraryName": "antd", "style": true }]] }
|
其它的缺啥装啥吧。