2012-10-08 6 views
0

없는이 전에 ocurr 에러에 관련된처럼 가 보이는 :Symbian/Phonegaps-1.10 | 형식 오류 : 표현의 결과는 '로컬 스토리지'[null가] 내가 심비안/폰갭 앱에서 로컬 스토리지에 액세스하려고 할 때이</p> <blockquote> <p>TypeError: Result of expression 'localStorage' [null] is not an object</p> </blockquote> <p>을받을 객체

TypeError: Result of expression 'window.widget.preferenceForKey' [undefined] is not a function. that ocurr in line var pref = window.widget.preferenceForKey(Storage.PREFERENCE_KEY);

function Storage() { 
    this.available = true; 
    this.serialized = null; 
    this.items = null; 

    if (!window.widget) { 
     this.available = false; 
     return; 
    } 
    var pref = window.widget.preferenceForKey(Storage.PREFERENCE_KEY); 

    //storage not yet created 
    if (pref == "undefined" || pref == undefined) { 
     this.length = 0; 
     this.serialized = "({})"; 
     this.items = {}; 
     window.widget.setPreferenceForKey(this.serialized, Storage.PREFERENCE_KEY); 
    } else { 
     this.serialized = pref;'({"store_test": { "key": "store_test", "data": "asdfasdfs" },})'; 
     this.items = eval(this.serialized); 
    } 
} 

내가 t 그것을 할 방법을 알고 난`을 돈 로컬 스토리지를 해결해야 할 것으로 보인다. 해결 방법은 없습니까?

답변

1

저는 실제로이 문제로 혼란에 처했습니다.

간단한 해결 방법은 preferenceForKey를 모두 피하고 환경 설정을 사용하는 것입니다.

<script> 
    var value = "Information to be stored"; 
    var key = "key"; 
    widget.preference["key"] = value; 
</script> 

나중에이 정보를 조사 할 수 있습니다.

<script> 
    var value = widget.preference["key"]; 
    alert(value); 
</script> 

희망이 있습니다.