반응형
@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
반응형
'programing' 카테고리의 다른 글
타입스크립트에 롬복과 같은 것이 있습니까? (0) | 2023.06.07 |
---|---|
오류 발생 시 Bash 셸 스크립트에서 자동으로 종료 (0) | 2023.06.07 |
데이터 유형 생략(예: "unsigned int" 대신 "unsigned") (0) | 2023.06.07 |
파이플롯을 사용하여 평활선 그리기 (0) | 2023.06.07 |
부동 소수점 번호를 특정 정밀도로 변환한 다음 문자열로 복사 (0) | 2023.06.07 |