我想提出一个敬酒的消息与他的名字,我有一个变量的用户。可能吗?如果是这样,怎么样?
我想要做这样的事情:
this.toastCtrl.create({
message: "Welcome user.firstname" ,
duration: 3000
}).present();
其中user.firstname
包含我的用户的姓名。
PS:上面的代码不工作,则显示消息“欢迎user.firstname”
您可以添加参数来敬酒
async toastCtrl(msg) {
const toast = await this.toastController.create({
message: msg,
duration: 300
});
toast.present();
}
调用函数的变量
this.toastCtrl('Welcome ' + user.firstname);
简单地做:
this.toastCtrl.create(
{
message: "Welcome " + user.firstname,
duration: 3000
}
).present();