programing

@click 인수를 작업 방법으로 전달하는 방법은 무엇입니까?

minimums 2023. 6. 7. 22:26
반응형

@click 인수를 작업 방법으로 전달하는 방법은 무엇입니까?

API에서 데이터를 검색해야 합니다.@click에서 액션 방법으로 인수를 전달하려고 합니다.Vuex나는 행동을 파견합니다.method()하지만 어떻게 논쟁을 넘겨야 할지 모르겠습니다.value매개 변수내가 아는 한 조치는 실행되어야 합니다.mounted()하지만 다시 한번, 어떻게 해야 할지 고민하고 있습니다.이것은 제가 생산한 것이지만 작동하지 않습니다.

      // Component.vue
      <v-list-group
        v-for="item in items"
        :key="item.id"
        @click="setItemName(item.value)"
        no-action
        >

      methods: {
          setItemName(value) {
             this.$store.dispatch('custom/getAllAction', value) 
          }
      },

 
      // Vuex   
      const mutations = {
           getAll: (state, all) => state.allData = all, 
      }

      const actions = {
          async getAllAction({commit}, prod)
          {        
            const response = await axios.get(`https://localhost:44327/api/Items/allItems?product=${prod}`)
            commit('getAll', response.data)
          },
      }

언급URL : https://stackoverflow.com/questions/75928593/how-to-pass-click-argument-to-action-method

반응형