首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >未捕获ReferenceError:元素Ui Plus中未定义then

未捕获ReferenceError:元素Ui Plus中未定义then
EN

Stack Overflow用户
提问于 2021-07-09 10:06:24
回答 1查看 157关注 0票数 1

我正在使用vue3element-ui-plus来构建一个项目。

但是当我尝试在element-ui-plus中使用MessageBox时,出现了一个错误Uncaught ReferenceError: then is not defined

除了MessageBox之外,其他函数都很好用。

这是我的代码。请参考handleDelete函数。

代码语言:javascript
复制
    <script src="../js/vue.js"></script>
    <script src="../plugins/elementui/index.js"></script>
    <script type="text/javascript" src="../js/jquery.min.js"></script>
    <script src="../js/axios-0.18.0.js"></script>
    <script>
        const app ={
            el: '#app',
            data(){
                return {
                    pagination: {
                        currentPage: 1,
                        pageSize: 10,
                        total: 0,
                        queryString: null
                    },

                    formData: {},


                }
            },
            created() {
                this.findPage();
            },
            methods: {
                findPage() {
                    var param = {
                        currentPage: this.pagination.queryString == null ? this.pagination.currentPage : 1,
                        pageSize: this.pagination.pageSize,
                        queryString: this.pagination.queryString
                    };
                    axios.post("/checkitem/findPage.do",param).then(res => {
                        this.pagination.total = res.data.total;
                        this.dataList = res.data.rows;
                    });

                },
                resetForm() {
                    this.formData = {};
                },
                handleDelete(row) {
                    this.$confirm("Do you want to delete the record?","Warning",{
                        confirmButtonText: "Yes",
                        cancelButtonText: "No",
                        type: "warning"
                    }).then(() => {
                        console.log("delete record");
                        axios.get("/checkitem/delete.do?id="+row.id).then(res => {

                        });
                    }).catch(() => {

                    });


                }
            }
        };
        Vue.createApp(app).use(ElementPlus).mount("#app");
<script>
EN

回答 1

Stack Overflow用户

发布于 2021-07-09 10:36:39

@Oliver你可以试着让你的函数成为async。见下文

代码语言:javascript
复制
async handleDelete(row) {
  try {
      await this.$confirm("Do you want to delete the record?","Warning",{
        confirmButtonText: "Yes",
        cancelButtonText: "No",
        type: "warning"
    })
    console.log("delete record")
    axios.get("/checkitem/delete.do?id="+row.id)
  } catch (error) {
    // handle error
  } finally {
    // something else if you need
  }
})

但问题是,在触发执行删除之前,您是否打算等待用户确认/取消单击?

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68310445

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档