The simple question of async/await

  async submitForm(formName) {
        this.$refs[formName].validate((valid) => {
            if (valid) {
                const res = await scdup(this.ruleForm);
            }
            return false;
        });
    },
    scduppromisevueawait
May.06,2022

is not an vue error, but a js error. Await can only be used in async functions. Your function is not async, and you should just add


[read teacher Ruan Yifeng's article] http://es6.ruanyifeng.com/-sharpdo...


await can only be used in async functions. You can rewrite

in this way.
async submitForm(formName) {
    this.$refs[formName].validate(async (valid) => {
        if (valid) {
            const res = await scdup(this.ruleForm);
        }
        return false;
    });
}

just make sure that validate supports promise callback

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b9ea3b-2f41c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b9ea3b-2f41c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?