DIALOG.close();
时间: 2024-03-16 19:47:28 浏览: 23
DIALOG.close()是一个关闭对话框的方法,它应该被绑定到特定的对话框对象上。如果您遇到了DIALOG.close()无效的问题,请确保您已经正确地初始化和绑定了该对话框对象,例如:
```
var dialog = document.getElementById("myDialog");
dialog.showModal();
// 执行一些操作
dialog.close();
```
在这个例子中,您需要先获取对话框元素,然后使用showModal()方法显示对话框。在对话框关闭之前,您需要执行一些操作,然后使用close()方法关闭对话框。如果您仍然遇到问题,请提供更多关于您的代码和对话框的信息,以便我更好地帮助您解决问题。
相关问题
DIALOG.close();失效
可能是因为在执行DIALOG.close()之前,没有正确初始化或绑定对话框。请确保在执行DIALOG.close()之前正确初始化对话框并绑定所有必要的参数。此外,您还可以尝试使用其他方法来关闭对话框,例如使用jQuery的.hide()方法或使用原生JavaScript的.style.display属性来隐藏对话框。如果问题仍然存在,请提供更多关于您的代码和对话框的信息,以便我更好地帮助您解决问题。
这段代码有什么错误的地方:// 修改课程 editCourse() { // 提交到后端之前,先处理editedCourse的嵌入college的值,值需要串college的id即可 if(this.collegeId && this.collegeId != 'null'){ this.editedCourse.college = {id: this.collegeId}; } axios.put('/course/course/'+this.editedCourse.id + '?code='+ this.editedCourse.code + '&name=' + this.editedCourse.name + '&collegeId=' + this.collegeId ).then(res => { this.loadCourses(); //当修改成功,刷新页面 this.editing = false; this.$refs.dialog.close(); }else { alert('修改课程《' + this.editedCourse.name + '》失败'); this.editing = false; this.$refs.dialog.close(); } }).catch(err => { console.error(err); this.editing = false; this.$refs.dialog.close(); }); }
这段代码的错误在于axios.put()的括号位置不正确,导致代码块的结构出现问题,应该将axios.put()的闭合括号移动到loadCourses()函数的前面。同时,如果axios.put()请求失败,应该在catch块中处理错误,而不是在else块中处理。下面是修改后的代码:
```
// 修改课程
editCourse() {
// 提交到后端之前,先处理editedCourse的嵌入college的值,值需要串college的id即可
if (this.collegeId && this.collegeId != 'null') {
this.editedCourse.college = {id: this.collegeId};
}
axios.put('/course/course/'+this.editedCourse.id, {
code: this.editedCourse.code,
name: this.editedCourse.name,
collegeId: this.collegeId
}).then(res => {
this.loadCourses(); //当修改成功,刷新页面
this.editing = false;
this.$refs.dialog.close();
}).catch(err => {
console.error(err);
alert('修改课程《' + this.editedCourse.name + '》失败');
this.editing = false;
this.$refs.dialog.close();
});
}
```
相关推荐
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![js](https://img-home.csdnimg.cn/images/20210720083646.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)