代码如下:
$('#browseButton').click(() => {
document.getElementById('directory').value = dialog.showOpenDialog({
filters: [
{name: 'somefile.exe', extensions: ['exe']},
{name: 'All Files', extensions: ['*']}
],
properties: ['openFile']
});
});
HTML:
<form class="ui form">
<div class="field">
<label for="directory">SteamCMD Directory</label>
<div class="ui action input">
<input id="directory" type="text">
<button id="browseButton" class="ui secondary button">
<i class="icon folder open"></i>
Browse
</button>
</div>
</div>
</form>
使用语义UI
当我在“打开”对话框中单击“确定”时,将打开一个新对话框。我必须两次选择文件才能注册document.getElementById('directory').value
。
答案 0 :(得分:0)
我认为这将解决此问题:
document.getElementById('browseButton').onclick = () =>
{
var file =document.getElementById('directory').value
dialog.showOpenDialog((file) => {
filters: [
{name: 'somefile.exe', extensions: ['exe']},
{name: 'All Files', extensions: ['*']}
],
properties: ['openFile']
});
});