0
我有以下typescript
類,擺脫localStorage
在TypeScript泛型方法中將變量轉換爲T?
export class LocalStorageHelper {
public static GetItemValue<T>(key: string): T {
let value: string = localStorage.getItem(key);
// if(typeof T == 'string') return value;
// return (Convert JSON.parse(value) To T)
}
}
我怎麼可以這樣做的打字稿註釋行模式?