- 我想给三个输入框赋值, 简单三句话,是可以的, 如图片显示也是成功的
if (this.erpRef.doc) {
this.downInfoUrl = this.erpRef.doc.url || ''
this.downInfoUser = this.erpRef.doc.user || ''
this.downInfoPwd = this.erpRef.doc.password || ''
}
- 后来由于类似的输入框很多, 我就想把这种写成公用的赋值方法, 只要传入对象, 和要被赋值的字段
...
this.updateDocInfo(this.erpRef.doc, this.downInfoUrl, this.downInfoUser, this.downInfoPwd)
...
updateDocInfo(system: Nullable<UrlAuth>, url: string, user: string, password: string) {
if (system) {
url = system.url || ''
user = system.user || ''
password = system.password || ''
}
}
执行方法后, 我发现这样却没有赋值成功, 是不是因为this对象没有传过去啊? 求解
你赋值到形参上,没用,实参不会变化。