确认未定义参考错误?

时间:2016-12-25 19:54:41

标签: javascript atom-editor

每次我尝试使用confirm()命令时,都会说没有定义确认。重要的是要注意我在Atom.io IDE中进行编程,并且我正在使用Script包来编译和运行我的程序。这是我试图运行的程序:

if ("atom".length >= 6)
{
  console.log("The statement is true")
}
else
{
  confirm("The statement is false")
}

2 个答案:

答案 0 :(得分:0)

Atom的脚本包不会使用DOM或浏览器API运行JS,包括alertconfirm,甚至window。您应该从浏览器运行脚本。

在这个StackSnippet中运行它,应该没问题:

if ("atom".length >= 6)
{
  console.log("The statement is true")
}
else
{
  confirm("The statement is false")
}

答案 1 :(得分:0)

Atom API提供t.AddOrUpdate("boo", (object)null, (k, v) => null); ,有关详细信息,请参阅documentation

示例

atom.confirm()