3

我正在尝试为我正在处理的工作流显示一个简单的对话框,但是使用 JXA 我不断收到错误:期望对象说明符,参数没有对象说明符。我不知道为对象说明符传递什么。我的代码在下面,它在我调用对话框的第 11 行出现问题

function run() {

    app = Application.currentApplication();
    app.includeStandardAdditions = true;
    //Error Here
    var who = app.displayDialog('Whose server is this?', {
        withTitle: 'Whose Server...'
    })

    return who
}
4

2 回答 2

1

阅读这本关于用户交互的非官方食谱,它可以帮助我了解这些警报。

详细说明:

function prompt(text, defaultAnswer) {
  var options = { defaultAnswer: defaultAnswer || '' }
  try {
    return app.displayDialog(text, options).textReturned
  } catch (e) {
    return null
  }
}
于 2015-07-13T02:53:57.287 回答
-2

来自 Gary @ macmost.com https://www.youtube.com/watch?v=GcPUJzmEuKE @ 8:47

app = Application.currentApplication();
app.includeStandardAdditions = true;

color = app.displayDialog("What is your favorite color?", { defaultAnswer: "" }).textReturned;

if (color == "red") {
    app.displayDialog("I like red too!");
} else {
    app.displayDialog("Interesting, I like red myself.");
}
于 2021-05-09T07:04:13.930 回答