可以使用条件语句来判断form表单里的state状态是否为0。可以在if语句中添加条件判断,判断this.form.state是否等于0。示例代码如下:

edit() {
    if (this.form.staffid == undefined) {
        if (this.form.state == 0) { // 判断state是否为0
            console.log(this.form.state)
            instance.post("/staffs", this.form).then(res => {
                if (res.date.code == 0) {
                    instance.get("/branchs").then(res => {
                        this.tableData = res.data.data;
                    })
                    this.form = {}
                }
            })
        } else {
            // state不为0的逻辑处理
            // ...
        }
    } else {
        instance.put("/staffs", this.form).then(res => {
            if (res.date.code == 0) {
                instance.get("/staffs").then(res => {
                    this.tableData = res.data.data;
                })
                this.form = {}
            }
        })
    }
    this.dialogFormVisible1 = false
    this.dialogFormVisible2 = false
    this.form = {}
}

在上述代码中,我们在if语句中添加了条件判断this.form.state == 0,如果state为0,则执行相应的逻辑代码。如果state不为0,则执行相应的逻辑处理代码。

edit if thisformstaffid == undefined consolelogthisformstate instancepoststaffs thisformthenres = if resdatecode == 0

原文地址: https://www.cveoy.top/t/topic/jcak 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录