本地快取localstorage使用

2022-02-22 22:57:51 字數 481 閱讀 6350

最近做專案遇到乙個問題,即從「個人中心」點選進入「修改支付寶」,需要自動獲取使用者手機號怎麼做?

修改支付寶的api不提供使用者手機號資料,但是發現個人中心提供,於是想通過localstorage在個人中心頁面獲取到手機號然後儲存在本地快取,進入修改支付寶頁面後再獲取出來。

經簡單查詢用法和實驗,**如下:

var phonenumber = data.data.memberinfo.mobile; //將後台資料儲存在乙個變數中

if( window.locastorage )else //if else做localstorage的相容 localstorage不支援ie67         //個人中心頁面

var phonenumber = window.localstorage? localstorage.getitem("myphone"): cookie.read("myphone"); //獲取key值      //修改支付寶頁面

搞定!

060JS 本地儲存localStorage

doctype html en utf 8 viewport content width device width,initial scale 1.0 x ua compatible content ie edge document title head 生命週期永久生效,除非手動刪除否則關閉頁面也...

html5本地儲存Localstorage屬性

html5中,新加入了乙個localstorage特性,這個特性主要是用來作為本地儲存來使用的。並且在ie8以上的ie版本才支援localstorage這個屬性。儲存 localstorage.setitem key value 檢索 var check localstorage.getitem k...

HTML5本地儲存Localstorage的應用

localstorage可以說是對cookie的優化,使用它可以方便在客戶端儲存資料,並且不會隨著http傳輸,但也不是沒有問題 localstorage大小限制在500萬字元左右,各個瀏覽器不一致 localstorage在隱私模式下不可讀取 localstorage本質是在讀寫檔案,資料多的話會...