我有以下字符串,
String Place = "3030XR Amsterdam";
Run Code Online (Sandbox Code Playgroud)
我希望得到它
String postcode = "3030XR";
String City = "Amsterdam";
Run Code Online (Sandbox Code Playgroud)
有人可以帮助我.
我有一个 html 下拉选择控件,并且已将第一个选项值添加为Select. 还有其他几个选项可以从下拉菜单中选择。现在我想重置下拉值并将其设置回Select.
我如何在 React 中做到这一点?
这是我的代码
<select className="form-control" ref="Auditee" name="Auditee" onChange={this.handleChange.bind(this)}>
<option>Select</option>
{this.renderAuditee()}
</select>
<button type="button" className="btn btn-primary" onClick={this.handleClear}>Clear</button>
renderAuditee(){
let Auditeefiltered = this.state.review1data.map(element=> element.EEECPM).filter((value, index, self) => self.indexOf(value) === index)
return Auditeefiltered.map(element=>
<option>{element.toString().replace(/\[.*?\]/,'')}</option>
)
}
handleClear(e){
e.preventDefault();
this.setState({
filterData:[],
filter: false
});
Run Code Online (Sandbox Code Playgroud)
我不知道我应该如何重置选择下拉列表。任何帮助都会有所帮助
我的react-native项目不在开发模式下。
双选项卡 R 键不起作用,并且cmd + M不起作用..
我的另一个项目连接到localhost:8081,但我的项目没有连接到,localhost:8081但是构建成功。
帮我!!
没有错误。
在使用倒数计时器时,我希望能够在按下按钮时重新开始倒数计时,但是,由于没有得到任何反馈,我认为该按钮不起作用。有人能指出我正确的方向吗?下面是我要实现的精简示例代码。
export default class Example extends Component {
constructor(props) {
super(props);
this.state = {
timer: 10,
timesup: false,
timing: true,
showWelcome: true,
};
}
componentDidMount() {
this.clockCall = setInterval(() => {
this.decrementClock();
}, 1000);
}
startTimer = () => {
this.setState({
timing: true,
timer: 30,
showWelcome: false
})
}
decrementClock = () => {
this.setState((prevstate) => ({
timer: prevstate.timer - 1
}), () => {
if (this.state.timer === 0) {
clearInterval(this.clockCall)
this.setState({
timesup: true,
timing: false,
showWelcome: false,
})
} …Run Code Online (Sandbox Code Playgroud) This console.log is not working: It'll just print the previous state value as set is async.
const SomeCompo = () => {
const [count, set] = useState(0);
const setFun = () => {
console.log(count);
set(count + 1);
console.log(count);
}
return <button onClick={setFun}>count: {count}</button>
}
Run Code Online (Sandbox Code Playgroud)
I had to read the count in the render itself:
const SomeCompo = () => {
const [count, set] = useState(0);
console.log(count);
const setFun = () => {
set(count + 1);
}
return <button onClick={setFun}>count: …Run Code Online (Sandbox Code Playgroud) reactjs ×4
javascript ×3
react-native ×2
ecmascript-6 ×1
java ×1
react-hooks ×1
react-redux ×1
split ×1
string ×1