错误$ProfilePictureUrl未替换My Database(即Firebase实时数据库)中的图片id



我正在#js中开发谷歌助手,当用户点击我的链接时http://host/$Profile,它需要显示个人资料图片,但$Profile在我的数据库中,$Profile应该被替换为423466934206595086.jpg,它在我的数据库中。这是我的代码"按钮URL:"http://armws.sste.saiveeetha.com/Content/ProfilePicture/$ProfilePictureUrl"----->当我点击该url时,即$ProfilePictureUrl并没有替换图片Id………….我不知道该怎么做………请帮助我……!!

const EmpId = agent.parameters.EmpId;
var ref3 =  admin.database().ref().child("Table/");
var query3 = ref3.orderByChild("EmpId").equalTo(EmpId);
return query3.once("value",function(snapshot) {
snapshot.forEach(function(child) {
agent.add(`The Faculty name is  ` + child.val().FirstName);
agent.add(new Card({
title: ` Name:${child.val().FirstName}
Employee Id: ${child.val().EmpId}
Address:: ${child.val().Address}  
Email :  ${child.val().EmailId}
DOB : ${child.val().DateOfBirth}
Department: ${child.val().DepartmentName}`,
imageUrl: 'https://eencrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR7lF8oXwLpXitlwizIdXVM-cGRTGqi79X3I4t5oBlNfhGe8mKN3Dg',
text:  `Thanks for using Saveetha Google Assistant 💁n DR ${child.val().FirstName} 💁`,
buttonText: 'View Profile Picture',
buttonUrl: 'http://........./Content/ProfilePicture/$ProfilePictureUrl'

您正在使用JavaScript模板文字!错误的方式。

为了让这个buttonUrl: 'http://........./Content/ProfilePicture/$ProfilePictureUrl'被js解析,你需要把它重写为

buttonUrl: `http://........./Content/ProfilePicture/${ProfilePictureUrl}`

通过这种方式,JS将用其值替换变量ProfilePictureUrl

JS模板文字必须以反勾开头

var ProfilePictureUrl = 'World'; console.log(`Hello ${ProfilePictureUrl}`);

这将打印出Hello World到控制台

相关内容

最新更新