When searching, return the content page that still exists at the time of search.

After searching, return and still display the searched content.

demo
 el-input(
          v-model="keyWord",
          placeholder="按客户名称/域名查询",
          @keyup.enter.native="handleChange",
          clearable
        )
js

1. When searching and calling the interface, the content entered in the input box exists inside sessionStorage

 // 查询列表数据
    getData() {
    
    
      this.loading = true;
      this.savedParams.page = this.pageIndex;
      this.savedParams.size = this.pageSize;
      realmlist(this.savedParams)
        .then((res) => {
    
    
          console.log(this.savedParams);
          this.loading = false;
          sessionStorage.setItem('keyWord', this.keyWord) // 存入在sessionStorage里面
          if (res.data.code === 200) {
    
    
            console.log(res);
            this.tableData = res.data.data.list.map((v,index) => {
    
    
              return {
    
    
                ...v,
                index
              }
            });

            this.totalCount = res.data.data.total;
          }
        })
        .catch(() => {
    
    
          this.loading = false;
        });
    },

2. Take out the value stored in mounted in 赋值给 data里面定义

mounted(){
    
    
    if(sessionStorage.getItem('keyWord')){
    
    
      let keyWord = sessionStorage.getItem('keyWord')
      this.keyWord = keyWord //赋值给 data中的 keyWord
    }
    // console.log(sessionStorage.getItem('keyWord'),'1234567')

    this.handleChange();
  },

Guess you like

Origin blog.csdn.net/GikQxx21_wen/article/details/127636710