vue.js - vue中自定义filter的问题
本文介绍了vue.js - vue中自定义filter的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
小白今天啃vuex,在网上看的文档,如下
getters: {
openProjects: state => {
return state.projects.filter(project => !project.completed)
}
}
这是vuex中的一段,我没看懂什么意思,filter不是过滤器吗?需要两个参数啊,这个怎么没有名字?
上下文代码如下,摆脱懂得帮忙讲一下。
import Vue from 'vue'
import Vuex from 'vuex'
import axios from 'axios'
Vue.use(Vuex)
const store = new Vuex.Store({
state: {
projects: []
},
actions: {
LOAD_PROJECT_LIST: function ({ commit }) {
axios.get('/secured/projects').then((response) => {
commit('SET_PROJECT_LIST', { list: response.data })
}, (err) => {
console.log(err)
})
}
},
mutations: {
SET_PROJECT_LIST: (state, { list }) => {
state.projects = list
}
},
getters: {
openProjects: state => {
return state.projects.filter(project => !project.completed)
}
}
})
export default store
解决方案
此 filter 非彼 filter
https://developer.mozilla.org...
这篇关于vue.js - vue中自定义filter的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文