您好,我有两个文件使用相同的接口(interface)和变量,所以我试图将变量导入另一个 typescript 文件。该接口(interface)也是从全局接口(interface)文件导入的。
declare interface personInterface {
name: string;
surname: string;
}
export let d: personInterface = {
name: '',
surname: ''
};
我正在导入然后 d 到另一个文件中:
import { d } from "./file";
d = sessionStorage.getItem("person");
我收到以下错误: 无法分配给“d”,因为它不是变量。
最佳答案
import {d} from ...
就像
const d = ...;
这就是为什么你不能重新分配常量
关于typescript - 无法分配给 'd',因为它不是变量 typescript ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60262211/