问题
mobx中用修饰器@observable配置全局变量时,报以下错误:
(property) RootStore.name: string
对修饰器的实验支持功能在将来的版本中可能更改。在 “tsconfig” 或 “jsconfig” 中设置 “experimentalDecorators” 选项以删除此警告。ts(1219)
解决方法
方法一:设置VSCode选项
管理==>设置==>搜索experimentalDecorators==>打上勾
方法二:增加jsconfig文件
{
"compilerOptions": {
"experimentalDecorators": true,// 主要是这个
"target": "es5",
"allowJs": true
},
"exclude": [
"node_modules",
"dist"
],
}
方法三:增加tsconfig文件
在根目录下新建tsconfig.json文件
{
"compilerOptions": {
"experimentalDecorators": true, // 主要是这个
},
"exclude": ["node_modules"],
"include": ["src"]
}