我有 Vuex 状态:
export const slideModule = {
state: {
slideTimer: 6000,
},
mutations: {
UPDATE_SLIDER_TIME(state, time) {
state.slideTimer = time;
},
RESET_TO_DEFAULT(state) {
state.slideTimer = 6000;
},
},
actions: {
updateSlideTimer({ commit }, time) {
commit("UPDATE_SLIDER_TIME", time);
},
resetToDefault({ commit }) {
commit("RESET_TO_DEFAULT");
},
},
};
并想使用这些动作和突变来改变Vue 3 carouselautoplay
中的值,
<Carousel
v-if="isSlideLoad"
:mouseDrag="false"
:touchDrag="false"
:autoplay="timer" // this is dyamic!
:transition="400"
:wrap-around="true"
>
我如何获得新的状态值:
computed: {
....
timer() {
return this.$store.state.timer.slideTimer; // this works, I get new value as I expected
},
},
帮助,如何在不刷新轮播的情况下动态执行此操作?:)