项目中遇到的问题---vue+element对话框关闭后重新打开数据不清空

解决方法:

1、

<el-dialog
  title="提示"
  :visible.sync="channelBox"
  size="tiny"
  :before-close="closeImport ">
  <span>这是一段信息</span>
  <span slot="footer" class="dialog-footer">
    <el-button @click="dialogVisible = false">取 消</el-button>
    <el-button type="primary" @click="dialogVisible = false">确 定</el-button>
  </span>
</el-dialog>

js 

closeImport () {
        this.$refs.publicimport.channelName = ''
        this.channelBox = false
      },

记得取消按钮,也要写这个事件。

 

2、https://blog.csdn.net/qq_37104276/article/details/78739832

  • 2
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 7
    评论
可以通过以下步骤实现: 1. 在列表行添加一个编辑按钮,并绑定点击事件处理函数。 ```html <el-table-column> <template slot-scope="scope"> <el-button type="primary" icon="el-icon-edit" @click="handleEdit(scope.row)">编辑</el-button> </template> </el-table-column> ``` 2. 在`handleEdit`函数,设置一个标志变量`isEditing`为`true`,并记录当前编辑的行数据。然后打开一个`el-dialog`对话框,用于编辑数据。 ```js data() { return { isEditing: false, editingRow: null } }, methods: { handleEdit(row) { this.isEditing = true this.editingRow = row } } ``` ```html <el-dialog v-model="isEditing"> <el-form> <!-- 编辑表单内容 --> </el-form> <div slot="footer"> <el-button type="primary" @click="handleSubmit">提交</el-button> <el-button @click="handleCancel">取消</el-button> </div> </el-dialog> ``` 3. 在`handleSubmit`函数,先禁用编辑按钮,并在15秒后重新启用。然后关闭对话框清空标志变量和编辑行数据。 ```js handleSubmit() { // 禁用编辑按钮 this.isEditing = false this.editingRow = null this.disableEditButton() // 提交表单数据 // ... // 关闭对话框 this.isEditing = false }, disableEditButton() { // 禁用当前编辑行的编辑按钮 const row = this.editingRow const elButton = this.$refs.table.$el.querySelector(`.el-table__row[data-row-key="${row.id}"] .el-button`) if (elButton) { elButton.disabled = true setTimeout(() => { elButton.disabled = false }, 15000) } } ```
评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小蘑菇0629

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值