typescript 报错信息

Declaration of private instance field not allowed after declaration of private instance method. Instead, this should come at the beginning of the class/interface。
报错原因:声明的变量放在了方法之后了。
解决方法:位置调整到正确位置,声明的变量放到上面。
submitForm(formName) {
        this.$refs[formName].validate((valid) => {
          if (valid) {
            alert('submit!');
          } else {
            console.log('error submit!!');
            return false;
          }
        });
      },
报错原因:找不到 validate 。
解决方法:此处改为 (this.$refs['form'] as any).validate((valid: any)

其他 缺少 逗号, 分号,多余空格 等等很好理解 暂不赘述。

原文地址:https://www.cnblogs.com/jiaqi1719/p/13029885.html