我未能在此常数中设置一个值:
const targetedMessageTemplate = {
"query": createTargetedMessage(input: {
conversationId: '',
targetUserId: '',
targetDialogId: '',
annotations: [{
genericAnnotation: {
title: '',
text: ''
}
}]
})
};
呼叫此:
var test= targetedMessageTemplate;
test.annotations[0].title = 'Test title';
返回:
TypeError: cannot read '0' of undefined.
设置对话ID变量的值正常工作,但是访问注释数组似乎是一个问题。
对我所缺少的东西的任何暗示都得到了高度赞赏。谢谢
genericantation 对象键未编写。
test.annotations[0].genericAnnotation.title = 'Test title';
但是错误是不同的。您确定注释不是一个空数组吗?