赋值方法抽成公用方法后失效了

  1. 我想给三个输入框赋值, 简单三句话,是可以的, 如图片显示也是成功的
 if (this.erpRef.doc) {
   this.downInfoUrl = this.erpRef.doc.url || ''
   this.downInfoUser = this.erpRef.doc.user || ''
   this.downInfoPwd = this.erpRef.doc.password || ''
 }

图片描述

  1. 后来由于类似的输入框很多, 我就想把这种写成公用的赋值方法, 只要传入对象, 和要被赋值的字段
  ...
  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对象没有传过去啊? 求解

阅读 1.4k
1 个回答

你赋值到形参上,没用,实参不会变化。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题