How to refresh the page after adding a new page successfully with vue operation?

use the MessageBox component of element-ui as a pop-up window, but how to refresh the page after adding it?

    addUserData(done) {
      this.$ajax.post(this.$api.departmentData, this.form).then(res => {
        if (res.data.status == 200) {
          this.addUser = false;
          this.$message({
            type: "success",
            message: "!"
          });
        }
      });
    },
Mar.15,2021

generally does not refresh the page, and the experience is not good. You can call the API to retrieve the page data after judging that the page is returned successfully


location.reload ()?


generally speaking, my Vue page has a method to obtain data. For example, the method _ fetchData, can obtain data from the server and render List, in the callback function where the new data is successfully added. I will execute _ this._fetchData (), again to automatically refresh the data.


call the parent list interface after success.


write an initialization method to load data, and then call this initialization method


you should just refresh the data. After success, this.query (); will not be finished.

Menu