element-ui销毁子组件的方法

方法一:在子组件中加v-if=“dialogCreateVisible”,添加完信息关闭弹出框之后,再次添加信息时弹出框中各组件的内容为空。

    <el-dialog title="添加员工信息" :visible.sync="dialogCreateVisible">
      <Add ref="addInformation" v-if="dialogCreateVisible"></Add>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogCreateVisible = false">取 消</el-button>
        <el-button type="primary" :loading="createLoading" @click="addClick">确 定</el-button>
      </div>
    </el-dialog>

方法二:在添加信息的方法中用“this.xxx = null”清空数据。

createStaff() {
      let isPhone = this.phone();
      console.log(this.create.sex);
     let addressTest = this.create.address[0] + '/' + this.create.address[1];
      console.log(addressTest);
    if(isPhone){
      this.$http({
        method: "post",
        url: "/api/addStaff",
        params: {
          department: this.create.department,
          office: this.create.office,
          id: this.create.id,
          staffName: this.create.staffName,
          sex: this.create.sex,
          entryDate: this.create.entryDate,
          address: addressTest,
          phoneNumber: this.create.phoneNumber
        }
      })
        .then(response => {
          console.log(response.data);
          this.dialogCreateVisible = false;
          this.createLoading = false;
          this.create.office = null;
          this.create.id = null;
          this.create.staffName = null;
          this.create.sex = null;
          this.create.entryDate = null;
          this.create.address = null;
          this.create.phoneNumber = null;
          this.getTablePage();
        })
        .catch(function(error) {
          console.log(error);
        });
    } else {console.log("error phone");}
    }


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值