我尝试在我对Google助手的操作上添加一个按钮,但是该代码仅适用于第一个。在这里,我为那些不起作用的按钮添加了按钮:
'Biology': {
title: 'Biology',
text:'Press the button to visit our site for more info. Biology is an important subject for those who are willing to take it, and this website will provide you' +
'with the necessary skill for this subject.',
image: new Image({
url: 'https://www.edzuki.com/biology/Biology+Edzuki.jpg',
alt: 'Biology as a subject',
}),
button: new Button({
title:'Click for the Biology Page',
url: 'https://www.edzuki.com/biology/',
}),
并且由于某种原因,这一方法有效
'Art': {
title: 'Art',
text:'Press the button to visit our site for more info. Art is an important subject for those who are willing to take it, and this website will provide you' +
'with the necessary skill for this subject.',
image: new Image({
url: 'https://www.edzuki.com/art/Art.jpg',
alt: 'Art as a subject',
}),
buttons: new Button({
title: 'Click for Art',
url: `https://www.edzuki.com/art/`,
}),
display: 'WHITE',
},
用于const subjectCard(基本卡)。 助手不会抛出任何错误,只是没有可见的按钮。为什么是这样? 预先感谢。
答案 0 :(得分:1)
在第一个示例中,将按键button
用于按钮,但是在第二个示例中,将buttons
与“ s”一起使用。文档还建议您使用复数版本buttons
,并且您自己的代码应根据您的第二个工作示例向您展示此作品
https://developers.google.com/actions/assistant/responses#basic_card
例如
'Biology': {
title: 'Biology',
text:'Press the button to visit our site for more info. Biology is an important subject for those who are willing to take it, and this website will provide you' +
'with the necessary skill for this subject.',
image: new Image({
url: 'https://www.edzuki.com/biology/Biology+Edzuki.jpg',
alt: 'Biology as a subject',
}),
buttons: new Button({
title:'Click for the Biology Page',
url: 'https://www.edzuki.com/biology/',
}),