<table id="tt">
<tr v-for="(d, a) in da1" >
<td><input type="checkbox" v-bind:click="select"></td>
<td>
<input type="text" v-bind:value="d" readonly="true"/>
</td>
<td >
<input type="text" v-bind:value="a" readonly="true" style="width: 500px;">
</td>
</tr>
</table>
<script>
Vue.createApp({
data:function(){
return{
da1:{1:"a",2:"b",3:"c",4:"d",5:"e",6:"f"}
}
},
methods:{
select:function(){
if(check状态){
// 当前行两个 text 可以编辑
}
else{
// 当前行两个 text 不可以编辑
}
}
}
}).mount("#tt")
</script>
vue3练习,
table里,用v-for生成了几行表格,
我想当选中左边的 check时 ,同一行的两个 input text 变成可编辑状态;取消选中,就不可编辑
但是有两个问题
1 我该怎么取得check的状态??
百度搜到一些方法,但都出错
2 check 和edit都是用for生成的。如果设置id 那for循环生成时,每个check(或edit)的id 不都是相同的吗?
那要用id的话要怎么办?
因为修改完还要保存的。
谢谢