Sometimes, we need to make corresponding operations according to the change of the value of the local cache in localstorage, which requires us to monitor localstorage:
First, we create a new stroage.js under the libs folder under src to rewrite the setItem event , when using setItem, trigger, window.dispatchEvent dispatch event
const Stroage = {
// 重写setItem事件,当使用setItem的时候,触发,window.dispatchEvent派发事件
dispatchEventStroage () {
const signSetItem = localStorage.setItem
localStorage