我想避免用户在更新尚未完成时单击另一行中的另一个按钮(编辑按钮)。我希望用户在编辑另一行之前先单击“保存”按钮。单击保存按钮时,如何删除文本框或将其恢复为原始形式?这是jsfiddle https://jsfiddle.net/2mh5yjeb/4/
new Vue({
el: "#app",
data: {
editMode: false,
users: [
{ name: 'mimi', email: 'wewe@s.com'},
{ name: 'sam', email: 'some@mk.com'},
{ name: 'kev', email: 'wewe'}
],
editedUser: null
},
methods: {
saveData () {
},
editData (user) {
this.beforEditCache = user
this.editedUser = user
}
}
})
答案 0 :(得分:2)
<button @click="editData(user)":disabled='editDisabled'>edit</button>
new Vue({
el: "#app",
data: {
editMode: false,
users: [
{ name: 'mimi', email: 'wewe@s.com'},
{ name: 'sam', email: 'some@mk.com'},
{ name: 'kev', email: 'wewe'}
],
editedUser: null,
editDisabled: false
},
methods: {
saveData () {
this.editDisabled = false
this.editUser = null
this.beforEditCache = null
this.editedUser = null
},
editData (user) {
this.editDisabled = true
this.beforEditCache = user
this.editedUser = user
}
}
})
这里是jsfiddle,希望对您有所帮助:)