我正在尝试生成通用谷歌钱包通行证。我已经能够成功地做到这一点,但我遇到的问题是我无法看到我在 cardTemplateOverride 对象中覆盖的文本字段。这些是“联系人”和“点”字段。附上代码供参考。
async function createPassClass(req, res) {
// TODO: Create a Generic pass class
let genericClass = {
'id': `${classId}`,
'classTemplateInfo': {
'cardTemplateOverride': {
'cardRowTemplateInfos': [
{
'twoItems': {
'startItem': {
'firstValue': {
'fields': [
{
'fieldPath': 'object.textModulesData["points"]'
}
]
}
},
'endItem': {
'firstValue': {
'fields': [
{
'fieldPath': 'object.textModulesData["contacts"]'
}
]
}
}
}
}
]
},
},
};
}
async function createPassObject(req, res) {
// TODO: Create a new Generic pass for the user
let objectSuffix = `${req.body.email.replace(/[^\w.-]/g, '_')}`;
let objectId = `${issuerId}.${objectSuffix}`;
let genericObject = {
'cardTitle': {
'defaultValue': {
'language': 'en',
'value': 'Google I/O \'22'
}
},
'textModulesData': [
{
'header': 'POINTS',
'body': '1234',
'id': 'points'
},
{
'header': 'CONTACTS',
'body': '20',
'id': 'contacts'
}
]
};
}
;```
This is the exact code given in google codelab and it's not working as expected like it should show the Contacts and Points fields on the pass but it isn't.
是的,即使我也有同样的问题。但我从这里尝试了通用类和对象出了问题 - Google Wallet API Pass Creation
它们确实有效,我根据我的代码进行了修改。我相信这是因为引号