我尝试将display_1和diplay_2添加到我的突变变量中,并尝试将其记录到console.log中,但console.log(数据、加载、错误)的输出为(未定义、错误、未定义)
const CREATE_T09_SCREENSHOT = gql`
mutation
createT09ScreenShot(
$screenshot_window_1: String!,
$screenshot_window_2: String!,
) {
createT09ScreenShot(
screenshot_window_1: $screenshot_window_1,
screenshot_window_2: $screenshot_window_2,
) {
screenshot_window_1
screenshot_window_2
}
}
`;
const SaveLogsButton = () => {
const [createT09ScreenShot, { loading, error, data }] = useMutation(CREATE_T09_SCREENSHOT);
const handleClick = async () => {
const screenshotData = await saveImage();
if (screenshotData){
const { display_1, display_2 } = screenshotData;
createT09ScreenShot({
variables: {
screenshot_window_1: display_1,
screenshot_window_2: display_2,
},
});
}
console.log(data)
console.log(loading)
console.log(error)
};
我也尝试这样做,但它给予了我一个错误
const handleClick = async () => {
await saveImageFunction();
const { display_1, display_2 } = saveImage;
createT09ScreenShot({
variables: {
这就是错误
Unhandled Promise Rejection: TypeError: Right side of assignment cannot be destructured
1条答案
按热度按时间wrrgggsh1#
我认为您在
saveImage destructurable
对象的handleclick
函数内部有一些错误。您需要将
handleClick
函数代码替换为以下代码: