美文网首页
vue查询后返回保留搜索记录

vue查询后返回保留搜索记录

作者: 一枚小菜 | 来源:发表于2020-03-23 17:52 被阅读0次

搜索绑定的字段查询出数据,点编辑时传绑定的字段过去,编辑页返回时传query过去,query里面是页面的信息,商品名,商品编码,商品分类等......然后赋值

注意:选择分类时查询返回得到的是id,需要先created方法里调用获取分类列表,然后再调用init方法
parseInt是字符串转整数类型

   created() {
      this.getCategoryList()
    },
   methods: {
      init(){ 
        let page = this.$route.query.page
        let title = this.$route.query.title
        let categoryId = this.$route.query.categoryId
        if (categoryId) {
          this.searchData.conditions.categoryId = parseInt(categoryId)
          console.log(categoryId)
        }
        if (title) {
          this.searchData.conditions.title = title
        }
        if (page) {
          this.searchData.page.page = parseInt(page)
          this.getData(this.searchData.page.page)
        } else {
          this.getData(1)
        }
       }
      },
     getCategoryList() {
        let that = this
        let url = api.api.product.category.all
        axios.post(url).then(response => {
          let rData = response.data
          if (rData.code === 0) {
            that.categorylist = rData.list
            that.init();
          } else {
            this.$message.error('获取失败' + rData.msg)
          }
        })
      },
   edit(item) {
        let url = item.url;
        url = util.toUrl(url, this.searchData.conditions)
        url = util.toUrl(url, this.searchData.page)
        this.$router.push({
          path: url
        })
      },

相关文章

  • MySQL慢查询分析

    开启慢查询日志 慢查询时长设置 开启后重连 记录到表 记录未使用索引的查询 测试 慢查询分析 得到返回记录集最多的...

  • vue列表缓存keep-alive

    使用场景: 列表查询出约课记录之后,跳转到详情后再返回页面内容刷新,之前搜索的结果就没有了,为了解决这一问题,使用...

  • 史上最全的ElasticSearch系列之基础(二)

    查询 空搜索 最基本的搜索API表单是空搜索(empty search),它没有指定任何的查询条件,只返回集群索引...

  • Vue keep-alive防止重复渲染DOM总结

    一,VUE单页面应用文件实现返回上一页面时保留之前的数据 最近在做项目时,需要实现下面场景: 在页面查询列表,进入...

  • 小心 SQL NOT IN 子查询的结果含有 null 值时的陷

    如果 NOT IN 子查询中返回的任意一条记录含有空值,则查询将不返回任何记录。如果子查询字段有非空限制,这时可以...

  • jdbc中excute,excuteUpdate,excuteQ

    **executeQuery(String sql) **执行select语句,它返回的是查询后得到记录集(res...

  • 五 搜索引擎的查询系统

    查询系统直接面对用户,在接受用户的查询请求后,通过检索,排序及摘要提取等计算,将结果组织成搜索结果返回给用户 特点...

  • Mybatis-Plus分页查询不返回总数total

    设置searchCount属性为false示例 同理 分页查询返回总记录数的结果如下 分页查询不返回总记录数的结果如下

  • Elasticsearch之搜索

    空搜索 搜索API的最基础的形式是没有指定任何查询的空搜索 ,它简单地返回集群中所有索引下的所有文档: 返回的结果...

  • laravel 框架bug

    一、查询查询语句groupBy后再count()获取记录数,返回的是第一个分组的数量 这是laravel的GitH...

网友评论

      本文标题:vue查询后返回保留搜索记录

      本文链接:https://www.haomeiwen.com/subject/xicayhtx.html