我有这个代码和一个配置文件testType:
import React, { Component } from 'react';
import Select from "./components/Select/Select";
class App extends Component {
state = {
testType : [
{value : "test1", name : "Test1"},
{value : "test2", name : "Test2"},
]
}
render() {
return (
<>
<Select {...this.state.testType}/>
<Select {...this.state.testType}/>
</>
);
}
}
export default App;
我用它作为道具传递给选择组件,下面是它的代码Select.js:
import React from "react";
const selectoption = (props) => (
<select className="custom-select">
<option value={props.value}>{props.name}</option>
</select>
);
export default selectoption;
但它不起作用,我没有props在 select 元素中看到 test1 和 test2。
Helenr
泛舟湖上清波郎朗
慕哥9229398
相关分类