1

我在我的代码中完成了以下设置,但是没有显示快速回复。下面显示的是我的状态对象和渲染代码。[快速回复没有显示,我在代码中遗漏了什么吗? 1

state = {
       messages : [
        {
            _id: 1,
            text: 'My message',
            "quickReplies":[
                {
                  "contentType":"text",
                  "title":"Yes",
                  "imageUrl":"http://example.com/img/yes.png"
                },
                {
                  "contentType":"text",
                  "title":"No",
                  "imageUrl":"http://example.com/img/no.png"
                }
              ]
          }],  
    }

我的渲染方法如下

render() {
        return (
            <View style={{ flex: 1, backgroundColor: '#fff' }}>
                <HeaderIconExample color ='#1976d2' title ={"Digital Assistant"} />
                <GiftedChat
                    messages={this.state.messages}
                    onSend={messages => this.onSend(messages)}
                    onQuickReply={quickReply => this.onQuickReply(quickReply)}
                    user={{
                        _id: 1
                    }}
                />
                <KeyboardSpacer />
            </View>
         );
    }

但是,当应用程序执行时,只显示消息对象的文本属性。请参阅下图了解更多详情。

4

1 回答 1

2

快速回复格式错误: 在此处输入图像描述

你应该把它改成这样

  message: [{
     _id: 1,
     text: "text",
     createdAt: new Date(),
     user: user,
     quickReplies: {
         type: 'radio' // or 'checkbox'
         values: [{
             title: "yes"
             value: "yes"
         },{
             title: "no"
             value: "no"
         }]  
      }
}]
于 2020-04-11T04:02:12.717 回答