我有一个javascript函数,它返回以下输出:
[ TextCommand { _textPattern: 'ping', _handler: 'pingCommand' } ]如何在使用console.log时直接输出文本"ping“
我尝试了一下,但失败了:
console.log(entry._commands.TextCommand._textPattern);仅供参考:
console.log(entry._commands);将输出:
[ TextCommand { _textPattern: 'ping', _handler: 'pingCommand' } ]我是否必须解析或字符串化才能得到结果?
发布于 2017-02-22 17:13:05
看起来_commands属性是一个数组(而不是对象),因此您应该获取它的第一个元素(0)来获取_textPattern属性。
console.log(entry._commands[0]._textPattern);发布于 2017-02-22 17:14:34
//entry。_commands是一个包含object console.log(entry._commands._textPattern)的数组;
发布于 2017-02-22 17:12:42
尝试使用
console.log(entry._commands[0]._textPattern);https://stackoverflow.com/questions/42387080
复制相似问题