更新函数应该接受一个选项对象。
只有当发送到更新的选项对象具有相应的属性时,才应设置传递给 Intercom 功能的对象的属性。
我该怎么做?
function update(options) {
Intercom('update', {
email: options.email || noProperty,
user_id: options.userId || noProperty,
});
}
最佳答案
您可以尝试在调用函数之前准备要更新的对象:
function update(options) {
var toUpdate = {};
if(options.email) {
toUpdate.email = options.email;
}
if(options.userId) {
toUpdate.user_id = options.userId;
}
Intercom('update', toUpdate);
}
关于javascript - 仅委托(delegate)选定的选项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40102805/