The usage of this.$set()---Switch the parent node, the input box is not cleared (the input box is cleared)

Click on the person to clear the input box,

Because the click event cannot clear the input box, the content of the input box cannot be obtained, so it cannot be cleared. Generally, it is very simple to assign the array to an empty array, but this time it does not work.

Use this.$set(); the request data part is not written

Check out the usage of this.$set in vue of this blog - I know the usage after the short book

<template>
    <el-tree
         :data="data" 
         :props="defaultProps"
         @node-click="handleNodeClick">
    </el-tree>
    <div v-for="(item,index) in tableData" :key="index">
        <span>{
   
   {item.name}}</span>
         <el-input 
            v-model="item.num" 
            placeholder="请输入内容">
         </el-input>
    </div>

</template>
<script>

    data(){
        retrun{
            tableDate:[]
        }
    },
    handleNodeClick(){
         for(let i = 0;i<this.tableData.length;i++){
               this.$set(this.tableData[i],'num',""); //'num'是key
        }

}
    


</script>

Guess you like

Origin blog.csdn.net/weixin_44126032/article/details/121082388