async handleEdit(index, rows) {
console.log(index, rows);
const id = rows.id;
console.log(id);
const name = await this.promptInput('请输入姓名', '请输入2-4个汉字');
const age = parseInt(await this.promptInput('请输入年龄', '请输入正整数'));
const sex = await this.promptInput('请输入性别', '请输入2-4个汉字');
const class1 = await this.promptInput('请输入班级', '请输入2-4个汉字');
console.log(name, age, sex, class1);
try {
const res = await axios.get(`http://localhost:9999/student/update/${id}?&name=${name}&age=${age}&sex=${sex}&class1=${class1}`);
console.log(res.data);
// 页面刷新
window.location.reload();
} catch (error) {
console.log(error);
}
},
async promptInput(message, validation) {
try {
const { value } = await this.$prompt(message, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
inputErrorMessage: validation,
});
return value.trim();
} catch {
this.$message({
type: 'info',
message: '取消输入',
});
}
}
elementui实现弹框输入
于 2023-04-14 15:20:23 首次发布