我是新来的反应。
我正在尝试使用下面的库来使用下拉菜单。
当我添加“required”属性时,它不会使用表单标记对其进行验证。
https://www.npmjs.com/package/react-select
import React from 'react';
import Select from 'react-select';
const options = [{
value: 'chocolate',
label: 'Chocolate'
},
{
value: 'strawberry',
label: 'Strawberry'
},
{
value: 'vanilla',
label: 'Vanilla'
},
];
class App extends React.Component {
state = {
selectedOption: null,
};
handleChange = selectedOption => {
this.setState({
selectedOption
});
console.log(`Option selected:`, selectedOption);
};
render() {
const {
selectedOption
} = this.state;
return ( <
Select value = {
selectedOption
}
onChange = {
this.handleChange
}
options …
Run Code Online (Sandbox Code Playgroud) 任何人都可以帮助我解决 .env-cmd 问题吗?
env-cmd 错误:无法在路径中找到 .env 文件:.env.development at getEnvFile C:\Users\Jake\project\fcmanager-frontend\node_modules\env-cmd\dist\get-env-vars.js
package.json 文件:
"scripts": {
"start": "env-cmd -f .env.development react-scripts start",
"build": "env-cmd -f .env.development react-scripts build",
"start-prod": "env-cmd -f .env.production react-scripts start",
"build-prod": "env-cmd -f .env.production react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
Run Code Online (Sandbox Code Playgroud)