# 实现修改

# 思路

1. 通过点击修改按钮触发模态框,弹出模态框,
2. 修改模态框中的数据响应到页面中

# HTML

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<div id="app">
<button type="button"@click="gai(index,item)" class="btn btn-primary" data-toggle="modal" data-target="#myModal">修改</button>
<div class="container">
<!-- 按钮:用于打开模态框 -->
<!-- 模态框 -->
<div class="modal fade" id="myModal">
<div class="modal-dialog">
<div class="modal-content">
<!-- 模态框头部 -->
<div class="modal-header">
<h4 class="modal-title">修改</h4>
<button type="button" class="close" data-dismiss="modal">&times;</button>
</div>
<!-- 模态框主体 -->
<div class="modal-body">
<div v-show="shou">
<input type="" v-model="form.name" name="" id="" value="" />
<input type="" v-model="form.age" name="" id="" value="" />
<button type="button" @click="an()">确定</button>
</div>
</div>
<!-- 模态框底部 -->
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
</div>
</div>
</div>
</div>
</div>
</div>

# js

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
let vm=new Vue({
el:"#app",
data:{
shou:false,
form: {
name: '',
age: ''
},
name: '',
age: '',
radio: '',
checked: [],
sao: '',
live: '',
index:''
},
methods: {
gai(i, k) {//点击修改
this.shou = !this.shou;
this.form.name = k.name;
this.form.age = k.age;
this.index = i;
},
an() {//点击修改里的确定
this.arr[this.index].name = this.form.name;
this.arr[this.index].age = this.form.age;
},
}
})
更新于

请我喝[茶]~( ̄▽ ̄)~*

高祥 微信支付

微信支付

高祥 支付宝

支付宝

高祥 贝宝

贝宝