vue中使用fullcalendar与axios与后端实现动态操作出现的问题
index.vue
methods: {
...mapActions({courseScheduling:'GetCourseSchedulingList' }),
search () {
this.params.startDate = '2022-01-01',
this.params.endDate = '2022-12-31',
// this.$courseScheduling.dispatch('GetCourseSchedulingList',this.params).then(res => {
this.GetCourseSchedulingList(this.params).then(res => {
if (res) {
this.calendarOptions.events = []
res.forEach(item => {
this.calendarOptions.events.push({
id: item.id,
title: item.title,
start: item.start,
end: item.end
})
})
}
})
},
},
mounted () {
this.search()
}
api中course-scheduling.js
import { axios } from '@/util/request'
export const getCourseSchedulingList = (params) => {
return axios({
url: '/api/time/searchTime',
method: 'get',
data: params
})
}
store中course-scheduling.js
import * as Api from '@/api/base/course-scheduling'
import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
const courseScheduling = new Vuex.store({
state: {
},
mutations: {
},
actions: {
GetCourseSchedulingList ({ commit }, param) {
return new Promise((resolve, reject) => {
Api.getCourseSchedulingList(param)
.then(res => {
resolve(res.data)
})
.catch(err => {
reject(err)
})
})
},
}
})
export default courseScheduling