Home>Article>Web Front-end> How Vue encapsulates a TodoList
This article will give you a detailed introduction to the method of encapsulating a TodoList in Vue. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.
Using Vue to encapsulate a simple Todolist case. At the same time, the technical means of browser local caching are added.
The browser cache is divided into two types: sessionStorage and localStorage, the two prototype chains are as follows:
It can be seen that their prototype chains are basically the same , the only difference is that
localStorage acts on the local cache and is persistent. Unless it is manually deleted or cleared, it will always exist in the browser
In this example, sessionStorage is used and a small encapsulation is carried out.
const storage = { set(key, value){ window.sessionStorage.setItem(key, JSON.stringify(value)); }, get(key){ return JSON.parse(window.sessionStorage.getItem(key)); }, remove(key){ window.sessionStorage.removeItem(key); }}export default storage;
TodoList 正在进行...{{dolistNumber}}
X
已经完成...{{dolist.length - dolistNumber}}
X
Recommended learning:vue.js tutorial
The above is the detailed content of How Vue encapsulates a TodoList. For more information, please follow other related articles on the PHP Chinese website!