1. 程式人生 > 實用技巧 >vue 查詢引數修改但頁面沒渲染,值已改變

vue 查詢引數修改但頁面沒渲染,值已改變

詳情頁面 路由上帶了引數並賦值展示成功,

這個由路由上帶的引數修改時,頁面沒渲染,值已改變,

如果此時去做別的不是路由賦值的引數修改,前面做的修改就刷新出來渲染成功

原始碼

 this.crud.query.bankId ="";
 this.crud.query.batchNo ="";
    this.$nextTick(() => {
      this.crud.data = [];
      if (this.$route.query.bankId) {
           //  this.crud.query.bankId = this.$route.query.bankId + "";
this.$set(this.query, "bankId", this.$route.query.bankId + ""); } if (this.$route.query.batchNo) { // this.crud.query.batchNo = this.$route.query.batchNo; this.$set(this.query, "batchNo", this.$route.query.batchNo); } this.crud.toQuery(); });

經過長久測試

發現這樣就可以了emmmm

    this.$set(this.crud.query, "bankId", "");
    this.$set(this.crud.query, "batchNo", "");
    this.$nextTick(() => {
      this.crud.data = [];
      if (this.$route.query.bankId) {
        this.crud.query.bankId = this.$route.query.bankId + "";
        // this.$set(this.query, "bankId", this.$route.query.bankId + "");
} if (this.$route.query.batchNo) { this.crud.query.batchNo = this.$route.query.batchNo; } this.crud.toQuery(); });