vue+elementui+axios中,前端通过表单向后端传送数据

<template>

<!-- 查询表单 -->
<el-form :inline="true" :model="querySearch" class="demo-form-inline">
<el-form-item label="站点名称">
<el-input
  v-model="queryParams.stationName"
   placeholder="站点名称"
   ></el-input>
   </el-form-item>
    <el-form-item label="站点状态">
   <el-select v-model="queryParams.status" placeholder="站点状态">
  <el-option label="正常" value="0"></el-option>
  <el-option label="禁用" value="1"></el-option>
   </el-select>
    </el-form-item>
   <el-form-item>
   el-button type="primary" @click="querySearch">查询</el-button>
</el-form-item>
</el-form>
</template>

<script>

  data() {
    return {
      tableData: [],
      multipleSelection: [],
      queryParams: {
        stationName: undefined,
        status: undefined,
      },
      pageNum: 1,
      pageSize: 10,
      total: null,
    };
  },

methods: {
// 获取数据
    getData() {
      axios
        .get("http://localhost:8989/system/station/list", {
          params: {
            pageNum: this.pageNum,
            pageSize: this.pageSize,
            stationName: this.queryParams.stationName,
            status: this.queryParams.status,
          },
        })
        .then((res) => {
          this.tableData = res.data.data.rows;
          this.total = res.data.data.total;
        });
    },
    querySearch() {
      this.stationName = decodeURI(this.queryParams.stationName); // 重点,如果有中文,要注意编码
      this.status = this.queryParams.status;
      this.getData();
    },
}
// 钩子函数
mounted() {
    this.getData();
  },
</script>

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值