发表于: 2020-02-04 22:16:29
1 1310
今天完成的事情:
今天完成了任务8相关的一些功能,
列表页面已经完全做好了,通过用vuex来从新构建了页面,免除了父子组建之前复杂的通讯,依靠vuex直接在组建内访问数据,因此删除了很多冗余代码。
const store = new Vuex.Store({
state: {
username: '',//记录用户名
pagination: '',//用来记录按钮个数
beclickBtn: 0,//记录被点击的按钮的index
articleListValue: '',//保存被请求过来的数据
vxType: '',
vxStatus: '',
vxSize: 10,
},
mutations: {
getUserName(state,val) {
state.username = val
},
VxToFirstPage(state) {
state.beclickBtn = 0
},
VxToLastPage(state) {
state.beclickBtn = state.pagination - 1
},
VxPageBtn(state,index) {
state.beclickBtn = index
},
VxBack(state) {
if(state.beclickBtn > 0) {
state.beclickBtn--
}
},
VxNext(state) {
if(state.beclickBtn < (state.pagination - 1)) {
state.beclickBtn++
}
},
VxDefine(state,val) {
state.vxSize = val[0]
state.beclickBtn = val[1] - 1
},
turnPage(state) {
axios.get('api/a/article/search/',{
params: {
page: state.beclickBtn + 1,
type: state.vxStatus,
status: state.vxType,
size: state.vxSize,
}
})
.then(res => {
state.articleListValue = res.data.data.articleList
state.pagination = Math.ceil(res.data.data.total / res.data.data.size)//向上舍入
})
},
turnTypeAndStatus(state , val) {
state.vxType = val[0]
state.vxStatus = val[1]
}
},
actions: {
vxSearch(context , val) {
context.commit('turnTypeAndStatus' , val)
context.commit('turnPage')
}
},
})
export default store
明天要做的事情:
进行任务9
评论