Implement todolist through two technologies: vue + vuex (detailed tutorial)

亚连
Release: 2018-05-31 16:02:05
Original
2101 people have browsed it

This article mainly introduces the implementation example code of vue vuex todolist. I think it is quite good. Now I will share it with you and give it as a reference.

todolist demo

I recently took a look at vuex again when I had time, and then wrote a small todolist demo. The principle is relatively simple, mainly because I have standardized it myself. Here’s how to write the code.

Download address: vue-test_jb51.rar

Rendering

Root component

  
Copy after login

Filter condition component

  
Copy after login

Add to-do Component

  
Copy after login

Single To-Do Component

  
Copy after login

vuex part (module)

const state = { list: [], types: ['ALL', 'UNDO', 'DONE'], filter: 'ALL' } const mutations = { handleAdd(state, item) { state.list = [...state.list, item] }, handleRemove(state, id) { state.list = state.list.filter(obj => obj.id !== id) }, handleToggle(state, id) { state.list = state.list.map( obj => (obj.id === id ? { ...obj, status: !obj.status } : obj) ) }, handleUpdateFilter(state, filter) { state.filter = filter } } export default { namespaced: true, state, mutations }
Copy after login

The above is what I compiled for everyone. I hope it will be helpful to everyone in the future.

Related articles:

JQuery Implementation of Enter Trigger Button Event Function Example

jQuery Cookie Implementation of Switching Skin Function

Sample code for interactions between Angular components

##

The above is the detailed content of Implement todolist through two technologies: vue + vuex (detailed tutorial). For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!