export function LocalStorage(key?: string) {
return WebStorage(localStorage, key);
}
export function WebStorage(webStorage: Storage, key: string) {
return (target: Object, propertyName: string): void => {
key = key || propertyName;
let storageKey = WebStorageUtility.generateStorageKey(key);
let storedValue = WebStorageUtility.get(webStorage, key);
...
Object.defineProperty(target, propertyName, {
get: function() { ... },
set: function(value: any) { .. },
});
}
};
가 어떻게 프로젝트가 각 CLI에 --aot
플래그와 함께 내장되어 다음과 같은 오류와 함께 주위를 얻을 수있는이 코드를 가지고 내 보낸 함수에 참조하여 기능을 대체하는 방법 .
ERROR in Error: Error encountered resolving symbol values statically. Function calls are not supported. Consider replacing the function or lambda with a reference to an exported function (position 15:12 in the original .ts file), resolving symbol WebStorage in the above file.
참고 15시 12분 위 코드에서 (target: Object, propertyName: string): void => {
인 위치.
각도 성분에서 LocalStorage
은 속성 장식자로 사용됩니다.
@LocalStorage() username: string = "";
어떻게 사용 않는'WebStorage '이것은 매우 일반적인 데코레이터처럼 보이기 때문에 작동해야합니다. 그래서 나는 당신이 그것을 어딘가에서 잘못 사용하고있을 것이라고 기대할 수 있습니다, 아마도 당신은 괄호를 잊어 버렸을 것입니까? '@WebStorage()' – PierreDuc
네, 이것은 데코레이터이지만 다른 데코레이터 인 LocalStorage와 SesaionStorage로 싸입니다. 완성 된 코드를 게시하고 요청할 것입니다. 현저하게 inner를 별도의 내 보낸 함수로 정의하면 외부 범위의 몇 가지 변수가 사용되므로 작동하지 않습니다. –
@ abdul-wahab, 문제를 해결 했습니까? 해결책을 게시 할 수 있습니까? – zhekaus