javascript - 如何在表格中的 react js 中添加下拉列表?
问题描述
var ListItem = React.createClass({ displayName: "ListItem",
getInitialState: function () {
return {fruit: this.props.value.product.fruit, meat: this.props.value.product.meat, vegetable: this.props.value.product.vegetable, total: 0 };
},
render: function () {
return (
React.createElement("tr", null,
React.createElement("td", null, React.createElement("input", { type: "text", name: "fruit", value: this.state.fruit, onChange: this.handleChange, placeholder: "fruit" })),
React.createElement("td", null, React.createElement("input", { type: "number", name: "meat", value: this.state.meat, onChange: this.handleChange, placeholder: "..." })),
React.createElement("td", null, React.createElement("input", { type: "number", name: "vegetable", value: this.state.vegetable, onChange: this.handleChange, placeholder: "..." })),
React.createElement("td", { className: "total" }, this.state.total)));
},
现在我想用下拉选项将水果、肉类和蔬菜更改为“形式”而不是“输入”,所以当我点击水果时,我将有“苹果、香蕉、草莓”的下拉选项。肉类选择将是“猪肉,牛肉,羊肉”等......
我试过使用
return React.createElement("select", {},
React.createElement("option", {value: "A"}, "Option A"),
React.createElement("option", {value: "B"}, "Option B"),
React.createElement("option", {value: "C"}, "Option C")
);
但它不起作用:(
解决方案
推荐阅读
- php - 如何在条码下添加文字:php-barcode-generator
- api - Heroku 服务器没有从本地文件中提取最新信息?
- python - Python:如何使用关键字列表在文本中搜索字符串
- rust - 即使使用“rustc_private”也找不到板条箱“rustc”
- angular - 根据状态更改多垫子进度条颜色?
- java - 将随机值分配给数组的问题
- python - 我不懂简单的二进制解码器代码。这段代码如何运作良好?
- r - R法线图中的阴影
- r - 带有 nginx/Ubuntu 20.04.1 和自定义域的闪亮应用程序/闪亮服务器
- python - 尝试在 Raspberry Pi 3 上使用旧版本的 Praw 时出错