Dom 如何在ATOM上调度命令?
我想知道如何在ATOM上发送命令 我尝试使用此代码:Dom 如何在ATOM上调度命令?,dom,atom-editor,dom-events,Dom,Atom Editor,Dom Events,我想知道如何在ATOM上发送命令 我尝试使用此代码: The command activate-killer-instinct-mode:test-command didn't get dispatched 激活:(状态)-> @订阅=新的CompositeDisposable @subscriptions.add atom.commands.add“atom工作区”, “激活杀手本能模式:测试命令”:=> console.log“你好,我是您的命令” @错误=错误 target=“atom工
The command activate-killer-instinct-mode:test-command didn't get dispatched
激活:(状态)->
@订阅=新的CompositeDisposable
@subscriptions.add atom.commands.add“atom工作区”,
“激活杀手本能模式:测试命令”:=>
console.log“你好,我是您的命令”
@错误=错误
target=“atom工作区”
commandName=“激活杀手本能模式:测试命令”
atom.commands.dispatch目标,commandName#这里是错误
console.log“命令”+commandName+“已调度”如果不是@error
console.error“命令”+commandName+“未被调度”if@error
我得到了这个输出:
The command activate-killer-instinct-mode:test-command didn't get dispatched
我读了那本书
::调度(目标,命令名)
╭─────────────╥─────────────────────────────────────────╮
│ 论点║ 描述│
╞═════════════╬═════════════════════════════════════════╡
│ 目标║ 开始冒泡的DOM节点│
| ║ 命令事件。│
╞═════════════╬═════════════════════════════════════════╡
│ 命令名║ 字符串,该字符串指示│
| ║ 命令调度|
└─────────────╨─────────────────────────────────────────┘
我认为错误在目标中,我不知道怎么做。感谢您的帮助。我认为错误在于您将字符串作为目标传递,而不是节点元素本身(对象,而不是字符串)。尝试在
target=atom.workspace.getActiveTextEditor()
中获取目标,或者任何适合您的方法。我解决了这个问题很久了。我相信错误在于您将字符串作为目标传递,而不是节点元素本身(对象,而不是字符串)。尝试在target=atom.workspace.getActiveTextEditor()
中获取目标,或者任何适合您的方法。我解决了这个问题很久了。很快我会写出解决方案。