내 vue.js 응용 프로그램에서 name
내 함수에 전달 하는 값을 읽으려고 합니다. 이것이 범위 문제라고 생각합니다. 주위를 둘러 보면 이것이 뚱뚱한 화살 기능으로 해결할 수 있다고 생각합니까?
다음은 변경 이벤트를 처리하는 데 사용하는 것입니다. 방법이 있습니까
async handleChange(event, name) {
console.log('name: ', name); // works
console.log('value: ', event.value); // works
try {
let response = await axios.patch(`/my/path`, {
name: event.value, // need to get the value from name
});
if (response.status === 200) {
//
} else {
console.error('Error: could not update. ', response);
}
} catch (error) {
console.error('Error: sending patch request. ', error);
}
}
나는 또한 이것을 시작하려고 시도했습니다.
handleChange: async (event, name) => {
...
}
axios 패치 내에서 뚱뚱한 화살표 기능을 사용하는 방법을 잘 모르겠습니다. 제안 해 주셔서 감사합니다!
완전히 명확하지는 않지만 객체 내부의 키로 이름을 전달하고 싶습니다. 만약 그렇다면 :
let response = await axios.patch(`/my/path`, {
[name]: event.value,
});
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다