1 仓库的税率选择部分标签颜色改变,但是接口500报错
import * as PropTypes from "prop-types"
import * as React from "react"
import { connect } from "utils"
interface D {
id: number
name: string
}
interface Props {
options: D[]
}
interface Context {
model: number
onRemove: (value: number) => void
editing: boolean
}
const styles = {
tag: {
height: 16,
lineHeight: "20px",
borderRadius: 4,
backgroundColor: "#eaa432",
padding: 10,
display: "inline-flex",
alignItems: "center",
color: "#233641",
marginRight: 25,
},
remove: {
width: 20,
height: 20,
display: "inline-block",
fontSize: 20,
marginLeft: 30,
cursor: "pointer",
color: "#4a90e2",
textAlign: "center",
},
}
const Tag: React.SFC<Props&WithStyles> = ({options, classes}, {onRemove, model, editing}: Context) => {
const option = options.find(({id}) => id === model)
return (
<div className={classes.tag}>
{option ? option.name : null}
{editing ? <div onClick={() => onRemove(model)} className={classes.remove}>{"\u00D7"}</div> : null}
</div>
)
}
Tag.contextTypes = {
model: PropTypes.number,
onRemove: PropTypes.func,
editing: PropTypes.bool,
}
export default connect<Props>(Tag, {styles})
直接修改背景颜色为eaa432
屏幕快照 2018-01-12 11.01.23.png
2 redux购物车例子.
createStore 创建一个 store来存放应用中所有的 state。应用中应有且仅有一个 store。
三个参数(函数reducer, 初始状态, enhancer)
返回值Store 保存了应用所有 state 的对象。改变 state 的惟一方法是dispatch action。也可以 subscribe state 的变化,然后更新 UI。
网友评论