我有 2 个 .ts 文件,
C.ts:
export let c: any = 10;
A.ts:
import { c } from "./C";
c = 100;
编译A.ts时报错:
error TS2539: Cannot assign to 'c' because it is not a variable.
我该如何解决?
最佳答案
将它放在一个类中,并使其成为静态的
export class GlobalVars {
public static c: any = 10;
}
从任何其他文件导入之后
GlobalVars.c = 100;
关于javascript - 错误 TS2539 : Cannot assign to 'c' because it is not a variable,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45997225/