検索

ホームページ  >  に質問  >  本文

javascript - localStorage的命名规则是怎样的?

for(var i=1;i<=setid;i++){
        localStorage.setItem("reason"+i,$("#reason"+i).val());
        //document.getElementById("yourID").value;
        alert(localStorage.getItem("reason"+i));
        
        }
        alert(localStorage[reason1]);
    });

localStorage[reason1]输出undefined

PHP中文网PHP中文网2818日前436

全員に返信(1)返信します

  • PHPz

    PHPz2017-04-10 16:42:11

    expression.identifier 
    expression[expression]
    
    localStorage["reason1"] === localStorage.reason1

    改成
    alert(localStorage.reason1)或者alert(localStorage["reason1"])

    返事
    0
  • キャンセル返事