vue数据回显中处理返回对象中多余参数

vue数据回显中处理返回对象中多余参数


处理返回对象中多余参数

  //获取response返回的对象
  var ob = response.data.user
  //获取dataFormform表单中的字段并遍历
  Object.keys(this.dataForm).forEach((key) => {
	if (ob[key] != null) {
	  //对象中时间字段的处理
	  if (key === 'createTime') {
		this.dataForm[key] = new Date(ob[key])
	  //对象中integer字段的处理
	  }if (key === 'userType') {
		this.dataForm[key] = parseInt(ob[key])
	  }else {
		this.dataForm[key] = ob[key]
	  }
	} else {
	  this.dataForm[key] = ''
	}
发布了94 篇原创文章 · 获赞 44 · 访问量 8万+

猜你喜欢

转载自blog.csdn.net/qq_43639296/article/details/96571037