javascript for automation [在finder中打开位置]

Cyr*_*gan 3 javascript osascript javascript-automation

我想弄清楚JXA(JavaScript for Automation)是如何工作的,所以尝试将如下的简单AppleScript翻译成JXA.

tell application "Finder"
    open location "smb://XXXXXXXX"
end tell
Run Code Online (Sandbox Code Playgroud)

我试过的是这里:

finder = Application("Finder")
finder.open({location:"smb://xxxxxx"})
Run Code Online (Sandbox Code Playgroud)

但是我失败了...,我是Apple的新手,并不是真正理解库中的描述.这是图书馆描述的方式open

open?(v) : Open the specified object(s)
open specifier : list of objects to open
  [using specifier] : the application file to open the object with
  [with properties record] : the initial values for the properties, to be included with the open command sent to the application that opens the direct object
Run Code Online (Sandbox Code Playgroud)

请告知我应该如何修改代码.^^谢谢

Cyr*_*gan 6

哦......我得到了答案......,没什么Application("Finder"),这是为了standardAdditions

app = Application.currentApplication()
app.includeStandardAdditions = true
app.openLocation("smb://xxxxxxxx")
Run Code Online (Sandbox Code Playgroud)