Qhov rai localStorage yog dab tsi?
Qhov rai localStorage yog dab tsi?

Video: Qhov rai localStorage yog dab tsi?

Video: Qhov rai localStorage yog dab tsi?
Video: Qhov Rai Hom Tshiab Zoo Nkauj Tshaj Plaws 2024, Kaum ib hlis
Anonim

LocalStorage yog hom web cia uas tso cai rau Javascript cov vev xaib thiab cov apps khaws thiab nkag mus rau cov ntaub ntawv hauv browser yam tsis muaj hnub tas sij hawm. Qhov no txhais tau hais tias cov ntaub ntawv khaws cia hauv qhov browser yuav pheej muaj txawm tias tom qab browser qhov rai tau kaw lawm.

Hais txog qhov no, qhov chaw khaws cia hauv browser yog dab tsi?

Hauv zos cia - Cov hauv zos cia siv cov localStorage kwv yees khaws cov ntaub ntawv rau koj lub vev xaib tag nrho ntawm lub hauv paus ruaj khov. Qhov ntawd txhais tau tias khaws cia hauv zos cov ntaub ntawv yuav muaj nyob rau hnub tom ntej, lub lim tiam tom ntej, lossis xyoo tom ntej tshwj tsis yog koj tshem nws.

Ib yam li ntawd, kuv yuav teeb tsa tus nqi cia hauv zos li cas? Cia setItem() Method

  1. Teem tus nqi ntawm cov khoom khaws cia hauv zos: localStorage.
  2. Tib yam piv txwv, tab sis siv kev sib kho cia es tsis txhob cia hauv zos. Teem tus nqi ntawm qhov kev teev tseg cia khoom:
  3. Koj tuaj yeem teeb tsa tus nqi los ntawm kev siv dot notation (obj.key):
  4. Koj tuaj yeem teeb tsa tus nqi zoo li no:

Hais txog qhov no, qhov chaw khaws cia hauv lub computer yog dab tsi?

chaw cia khoom - Khoos phis tawj Lus Txhais Ib lub hard drive lossis lub xeev cov tsav ncaj qha txuas rau lub cuab yeej raug xa mus. Lub sij hawm yuav siv los sib piv cov khaws cia nyob rau hauv lub unit los ntawm lub khaws cia nyob rau hauv cov servers hauv zos network lossis hauv Internet (saib SAN, NAS thiab huab khaws cia ).

Thaum twg kuv yuav tsum siv localStorage thiab sessionStorage?

localStorage - khaws cov ntaub ntawv tsis muaj hnub tas sij hawm. qhov rai. sessionStorage - khaws cov ntaub ntawv rau ib zaug (cov ntaub ntawv ploj thaum browser tab raug kaw)

Pom zoo: