可以使用条件语句来判断 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,则执行相应的逻辑处理代码。

JavaScript Form 表单 state 状态判断 - 如何判断修改时 form 表单里的 state 状态是否为 0

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

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