兼容不同传参数
兼容不同传参数 运行本地命令
兼容不同传参数 兼容不同传参数 运行本地命令
let output = if arg.len() == 0 { 使用 数组长度判断的 这里outout居然能接受后面的信息
#[tauri::command]
fn greet(command: &str,arg : Vec<String>) -> String {
let output = if arg.len() == 0 {
Command::new(&command).output().expect("Failed to execute command")
} else {
Command::new(&command).args(&arg).output().expect("Failed to execute command")
};
let output_str = String::from_utf8_lossy(&output.stdout).to_string();
output_str
}
vue
this.greetMsg = await invoke("greet", { command: 'ipconfig', arg:[] });