classPClocalStorage
cookielocalStorage
`
class ShopCarTool{
constructor(store){
// var shopCar = DB.getItem("shop-car").toJson()// localStorage
/* */
let shopCar={};
axios.get(url).then(res=>{
shopCar=res.data
})
if(!shopCar){
DB.setItem("shop-car", JSON.stringify(shopCar = {}))
}
this.$store = store
this.shopCarDB = shopCar
}
length() {//
var n = 0;
for(var i in this.shopCarDB){
n += this.shopCarDB[i].length
}
return n
}
}
`
localStorageshopCarDB
length()!
![][1]
length()shopCarDB
constructor
new Promiselength()this.shopCarDB = shopCar
localStorage