在我的 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 补丁中使用粗箭头函数。感谢您的任何建议!
                    
                    
                1 回答
                            慕田峪7331174
                            
                                
                            
                        
                        
                                                
                    TA贡献1828条经验 获得超13个赞
不完全清楚,但我猜您想将名称作为对象内部的键传递。如果是这样,请执行以下操作:
let response = await axios.patch(`/my/path`, {
[name]: event.value,
});
添加回答
举报
0/150
	提交
		取消
	