【TypeScript】Vue: Promise only refers to a type, but is being used as a value here.
问题描述
Vue: Promise only refers to a type, but is being used as a value here. Do you need to change your target library? Try changing the lib compiler option to es2015 or later.
原因分析
TypeScript的编译目标库版本过低,无法识别Promise
作为值使用。需要将tsconfig.json
中的lib
选项更改为es2015
或更高版本。
解决方案
- 在项目根目录创建 tsconfig.json
- 写入
{
"compilerOptions": {
"lib": ["es2015", "dom"]
}
}