问题描述:

点击确定时,前端控制台打印如下:

 但是实际上startStationName和endStationName均有值,如下所示:

代码:

<el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible" width="980px" @close="closeDialog">
      <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="170px">
        <el-row type="flex" class="row-bg">
          <el-col :span="12">
            <el-form-item label="起点:" prop="startStationName">
              <el-input v-model="ruleForm.startStationName" readonly  style="width: 240px;">
                <el-button type="primary" slot="append" icon="el-icon-search" @click="zdSelect('startStation')">选择</el-button>
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="终点:" prop="endStationName">
              <el-input v-model="ruleForm.endStationName" readonly  style="width: 240px;">
                <el-button type="primary" slot="append" icon="el-icon-search" @click="zdSelect('endStation')">选择</el-button>
              </el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row type="flex" class="row-bg">
          <el-col :span="12">
            <el-form-item label="运价:" prop="price">
              <el-input v-model="ruleForm.price" clearable style="width: 240px;"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible = false">取 消</el-button>
        <el-button type="primary" @click="submitForm('ruleForm')">确 定</el-button>
      </span>
    </el-dialog>

数据模型:

data() {return {
        ruleForm: {
          startStation:null,
          endStation:null,
          price: null
        },
    rules: {
    startStationName: [{ required: true, message: '请选择起点', trigger: 'change' }],
     endStationName: [{ required: true, message: '请选择终点', trigger: 'change' }],
     price: [{ required: true, validator: validateNumber, trigger: 'blur' }]
    },
 } },

后来发现是名称不一致导致的,修改如下:

data() {
      return {
        ruleForm: {
          startStationName:null,
          endStationName:null,
          price: null
        },
      }
    },

 

posted on 2024-04-29 10:48  周文豪  阅读(1046)  评论(0)    收藏  举报