1. 环境安装
* Linux解决ssh git clone失败的问题:ssh-keygen -t ed25519 -N '' -C "@swifthealth.cn" -f ~/.ssh/id_ed25519
* 安装Android Studio:首先安装JetBrains Toolbox,
* 借鉴https://blog.youkuaiyun.com/matrixbbs/article/details/122022074
* 遇到问题查询https://blog.youkuaiyun.com/Paramagnetism/article/details/124956975
2. 奇怪的知识
* scss计算calc(50%-66px)
* 数组.sort()方法会改变原数组,解决办法:data.slice().sort()不会改变原数组
* 安装.deb包的命令,sudo dpkg -i 包名.deb
* 支付宝小程序兼容taro富文本组件<RichText />安装 mini-html-parser2
* 命令:yarn add mini-html-parser2 --save -W
* 平移:
style={{
transform: 'translateY(-2px)',
// transform: 'scaleY(0.5)',
}}
// 还有一种写法,可以试试
style={[{transform: [{translateX: 10},{translateY: 20}]}]}
scss:transform:translateX(16px) translateY(-16px);
* onclick里面不需要加index,不然里面的立即执行函数不会调用正确的index
{this.props.list.map((item, index) => {
return (<View style={{ backgroundColor: 'red', margin: '10px' }} onClick={() => { this.props.removeData(index) }}>{item}</View>);
})}
* redux中间件和浏览器redux插件冲突解决方法
import {createStore, applyMiddleware, compose} from 'redux'
import reducer from './reducer'
import thunk from 'redux-thunk'
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({}):compose
const enhancer = composeEnhancers(applyMiddleware(thunk))
const store = createStore(
reducer,
enhancer
)
export default store
* 当子组件使用@connect连接器时,出现父组件调用子组件undefined的情况时
父组件里面使用:onRef={}
<ExpandableGroupItem
onRef={ref =>
this[`groupComponent_${item.groupId}`] = ref
}
item={item}
selectedUserIds={this.state.selectedUserIds}
onGroupCheckChange={this.onGroupCheckChange}
onSelectUser={this.onSelectUser}
/>
子组件在组件生成时,将组件实例this传递给onRef方法
componentDidMount(){
this.props.onRef(this);
}
参考:http://t.zoukankan.com/miraclesakura-p-13917969.html
参考:https://blog.csdn.net/qq_37638969/article/details/115115277
* scss图片背景:
.header {
background-size: 100%, 100%;
background-image: url('./images/fei_guo_hao_bgc@2x.png');
}
* 图片引用:
<Image
src={require('./images/zhuan_jia_hao@2x.png').default}
style={StyleSheet.transformRNStyle({
height: 18,
width: 65,
justifyContent: 'center',
alignItems: 'center',
})}
/>
* 微信小程序onShow和onLoad,映射componentDidShow()componentDidLoad()
* 日期格式化:
const dates = new Date();
conditions = {
startDate: !this.state.startDate ? moment(dates).format('YYYY-MM-DD') : this.state.startDate,
endDate: !this.state.endDate ? moment(dates).format('YYYY-MM-DD') : this.state.endDate,
};