大家好,我是 React 新手。我正在尝试使用反应钩子创建一个级联下拉列表,我的方法效果很好,但我觉得我的方法有问题。请检查此代码并告诉我有一种方法可以改进我的代码。提前致谢
import React, { useState } from 'react';
import './App.css';
function App() {
const[data, setName] = useState({
countrie:"",
state:""
});
let state;
const countrie =['Germany','India','France']
const gstate = ['Duesseldorf', 'Leinfelden-Echterdingen', 'Eschborn']
const istate = ['Delhi', 'Kolkata', 'Mumbai', 'Bangalore']
const fstate =['Auvergne','Bretagne','Corse','Centre']
if(data.countrie==="Germany"){
state = gstate.map((gstate,key)=> <option key={key} value={gstate}>{gstate}</option>)
}else if(data.countrie==="India"){
state = istate.map((istate,key)=> <option key={key} value={istate}>{istate}</option>)
}else{
state = fstate.map((fstate,key)=> <option key={key} value={fstate}>{fstate}</option>)
}
const countries = countrie.map((countrie,key)=> <option key={key} value={countrie}>{countrie}</option>)
function handleCountry(e){
setName({...data,countrie:e.target.value});
}
function handleStateChange(e){
setName({...data,state:e.target.value}); …Run Code Online (Sandbox Code Playgroud) 我的申请代码
public class Main extends Application {
private static Scene scene;
@Override
public void start(Stage stage) throws IOException {
FXMLLoader fxmlloader = new FXMLLoader(LoginControler.class.getResource("loging.fxml"));
scene = new Scene(fxmlloader.load());
stage.setScene(scene);
stage.setResizable(false);
stage.show();
}
public static void main(String[] args) {
launch();
}
}
Run Code Online (Sandbox Code Playgroud)
我试图使用终端在 javafx 应用程序之上运行,但出现此错误。请告诉我我在脚本中是否犯了错误。我已经使用maven-shade-plugin来构建具有依赖项的 jar
root@abc-abc2051A:~# java -jar --module-path /opt/javafx-sdk-11/lib --add-modules javafx.controls myjar-1.0.0-shaded.jar
Error: Invalid or corrupt jarfile /opt/javafx-sdk-11/lib
Run Code Online (Sandbox Code Playgroud)
应用运行环境