import React from 'react'
class EditProduct extends React.Component {
constructor(props) {
super(props)
}
render() {
return (
<div>
<ProductForm
handleChange={this.handleChange}
clickHandle={this.clickHandle}
product={this.props.product}
/>
</div>
)
}
}
const mapStateToProps = (state) => {
return {
product: state.ProductReducer.products[0]
}
}
export default connect(mapStateToProps)(EditProduct)
function ProductForm(props) {
console.log("props from edit", props); // Here i can gets props
return(
<form>
<div className="form-group">
<label htmlFor="productid">Sku</label>
<input type="email"
className="form-control"
id="sku"
name="sku"
aria-describedby="skuHelp"
onChange={props.handleChange}
value={props.sku}
placeholder="Enter SKU"/>
</div>
控制台输出:
delProd:id => {…} editProd:id => {…}历史记录:{长度:25,动作: “ PUSH”,位置:{…},createHref:ƒ,推入:ƒ,…} 位置:{路径名:“ /”,搜索:“”,哈希:“”,状态:未定义,键:“ hwy1de”} 匹配:{path:“ /”,url:“ /”,isExact:true,params:{…}} 产品:数组(1) 0:{sku:“ SD”,productName:“ prd”,描述:“ des”,持续时间:“ 231”,id:“ nUkHoRev”} 长度:1
我正在尝试在表单中列出值,但是它没有显示,但是我在道具中却获得了价值
如果我尝试在内部添加props.products [0] .sku,则表示未定义,除非在产品内部有任何东西,否则未定义。如何使用相同的表格来编辑和添加产品。请提前多谢指导
答案 0 :(得分:1)
您在这里通过 $ make
/Users/username/Desktop/dev/pv/paraview_build/superbuild/qt5/src/qtbase/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm:833:20: error: qualified reference to 'QFixed' is a constructor name rather than a type in this context
return QFixed::QFixed(int(CTFontGetUnitsPerEm(ctfont)));
在这里您正在获得产品?您的代码中缺少某些内容吗?
/Users/username/Desktop/dev/pv/paraview_build/superbuild/qt5/src/qtbase/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm
答案 1 :(得分:0)
您可以尝试
<form>
<div className="form-group">
<label htmlFor="productid">Sku</label>
<input type="email"
className="form-control"
id="sku"
name="sku"
aria-describedby="skuHelp"
onChange={props.handleChange}
defaultValue={props.products && props.products.sku}
placeholder="Enter SKU"/>
</div>
希望这会解决