Javascript 如何将vuex模块getter与composition api一起使用?

Javascript 如何将vuex模块getter与composition api一起使用?,javascript,vue.js,vuex,vuejs3,Javascript,Vue.js,Vuex,Vuejs3,这是我的vuex getter const getters = { getMovieById: state => id => { debugger; return state.movies.find(movie => movie.id === id); } }; 我正在导入组件中的模块 import movieMod from "../store/modules/movies"; 我正在反应对象中存储getter的返回值 movie = mov

这是我的vuex getter

const getters = {
 getMovieById: state => id => {
 debugger;
 return state.movies.find(movie => movie.id === id);
 }
};
我正在导入组件中的模块

import movieMod from "../store/modules/movies";
我正在反应对象中存储getter的返回值

 movie = movieMod.getters.getMovieById(parseInt(props.id));
这是返回我下面的函数

(id) {
  debugger;
  return state.movies.find(function (movie) {
    return movie.id === id;
  });
}

尝试以下
movie=movieMod.getters.getMovieById(state)(parseInt(props.id)
getMovieById
是一个高阶函数,它是一个返回函数的函数。在您的情况下,您没有执行返回的函数。

我发现我的方法是错误的,我应该使用composition API中的挂钩,而不是导入模块

从“vuex”导入{useStore}

  setup(props) {
   const store = useStore();
  return {
  movie: computed(() => store.getters.getMovieById(parseInt(props.id)))
  };
 }