How to solve the problem of elementUI selecting date push to display undefined? in object

github address

Q1:
functions onSubmit () and reset () do code reuse

Q2:
onSubmit () conditional statement looks stupid, can it be optimized

Q3:
Select the date push into the userList object and display undefined

04:
how element-ui displays two input on the same line

05:
how the input of element-ui controls the length

<template>
  <el-tabs v-model="activeName2" type="card">
    <el-tab-pane label="" name="first">

      <!--  -->
    <el-form
      ref="form"
      :model="form" 
      label-width="80px">
      <el-form-item label="">
        <el-col :span="4">
          <el-date-picker 
            type="date" 
            placeholder="" 
            v-model="form.date" 
            style="width: 100%;">
          </el-date-picker>
        </el-col>
      </el-form-item>
      <el-form-item label=""> 
        <el-col :span="6">
          <el-input v-model="form.name"></el-input>
        </el-col>
      </el-form-item>
    <el-form-item label="">
      <el-select v-model="form.province" placeholder="">
        <el-option label="" value=""></el-option>
      </el-select>
    </el-form-item>
    <el-form-item label="">
      <el-select v-model="form.city" placeholder="" label-width="1px">
        <el-option label="" value=""></el-option>
      </el-select>
    </el-form-item>
    <el-form-item label="">
      <el-col :span="6">
        <el-input v-model="form.address"></el-input>
      </el-col>
    </el-form-item>
    <el-form-item label="">
      <el-col :span="6">
        <el-input v-model="form.zip"></el-input>
      </el-col>
    </el-form-item>
    <el-form-item>
      <el-button type="primary" @click="onSubmit"></el-button>
      <el-button @click="reset"></el-button>
    </el-form-item>
  </el-form>

  <!--  -->
    <hr>

    <!--  -->
    <el-table
    :data="userList"
    style="width: 100%"
    max-height="400">
    <el-table-column
      fixed
      prop="date"
      label=""
      width="150">
    </el-table-column>
    <el-table-column
      prop="name"
      label=""
      width="120">
    </el-table-column>
    <el-table-column
      prop="province"
      label=""
      width="120">
    </el-table-column>
    <el-table-column
      prop="city"
      label=""
      width="120">
    </el-table-column>
    <el-table-column
      prop="address"
      label="">
    </el-table-column>
    <el-table-column
      prop="zip"
      label=""
      width="120">
    </el-table-column>
    <el-table-column
      fixed="right"
      label=""
      width="120">
      <template slot-scope="scope">
        <el-button
          @click.native.prevent="deleteRow(scope.$index, userList)"
          type="text"
          size="small">
          
        </el-button>
      </template>
    </el-table-column>
  </el-table>
    </el-tab-pane>
    <el-tab-pane label="" name="second">
      
    </el-tab-pane>
    <el-tab-pane label="" name="third"></el-tab-pane>
    <el-tab-pane label="" name="fourth"></el-tab-pane>
  </el-tabs>
  
</template>

<script>
  export default {
    data() {
      return {
        activeName2: "first",
        userList:[{}],
        form:{
          date:"",
          name:"",
          province:"",
          city:"",
          address:"",
          zip:""
        }
      };
    },
    methods: {
      deleteRow(index, rows) {
        rows.splice(index, 1);
      },
      onSubmit(){
        if( this.form.name=="",
            this.form.date=="",
            this.form.name=="",
            this.form.province=="",
            this.form.city=="",
            this.form.address=="",
            this.form.zip==""){
              alert("")
        }else{
          this.userList.push({
          date:this.form.date,
          name:this.form.name,
          province:this.form.province,
          city:this.form.city,
          address:this.form.address,
          zip:this.form.zip,
          });
          this.form.date=""
          this.form.name=""
          this.form.province=""
          this.form.city=""
          this.form.address=""
          this.form.zip=""
        }
      },
      reset(){
        this.form.date=""
        this.form.name=""
        this.form.province=""
        this.form.city=""
        this.form.address=""
        this.form.zip=""
      }
    },
    mounted(){
        this.$http.get("src/userList.json")
        .then((res)=>{
        this.userList = res.data
        console.log(res)
      })
      
    }
  }
</script>
<style>

</style>

Mar.02,2021

undefined problem, I think it may be because of the problem you are dealing with on the server side, you can check this part of the code. That is, how the data is saved at the back end after you submit it, and what the userList field you get to is like.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e9a9cc-4ecbd.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e9a9cc-4ecbd.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?