Data on the use of mpvue data encountered in the development of small programs do not reset problem

When using mpvue develop small programs, product reviews do this one, encountered a problem, that is, each time evaluating a finished product, go to another product evaluation, product evaluation data page is not reset, access to a lot of information Finally, inside pass by onLoad

Object.assign (this $ data, this $ options.data ()..); Manually reset the data, the data can be reset in the onShow, but page loading, the onLoad inside the first method is invoked, and in the onLoad need to get inside pass parameters page, if your method to interact with back-end data is placed in onShow, and also need a front page of mass participation, then, when onShow manually reset data, will you get out of mass participation also reset,
 onLoad(option) {
    Object.assign(this.$data, this.$options.data());
    this.primaryColor = wx.getStorageSync("mainColor");
    this.GetUserEvaluateDetailsDTO.orderItemKeyId = option.orderItemKeyId;
    this.GetEvaluateStateDTO.orderItemKeyId = option.orderItemKeyId;
    if (wx.getStorageSync('token')) {
      this.userAuth = true;
    } else {
      this.userAuth = false;
    }
    // this.evaluteObj.evaluateResultDTO = {};
    // this.evaluteObj.appendEvuluateResultDTO = {};
    // this.isActive = false;
    // this.commentList = [];
    // this.replyList = [];
    wx.showLoading({
      title: '加载中',
    })
    // this.commentState = 'initial';
    // this.page = 1;
    this.reqGetDetails();
    this.reqGetGoods();
  }

Commented that I need to reset the data, the page is loaded, the data is not automatically reset, I can pass in the onload

Object.assign(this.$data, this.$options.data()); 

Reset, greatly reducing the amount of code. First time to write, write wrong place, please correct me.

Guess you like

Origin www.cnblogs.com/zmhl/p/11373171.html