Skip to content

Commit

Permalink
补充错误回调
Browse files Browse the repository at this point in the history
  • Loading branch information
wangcuijuan committed Dec 19, 2024
1 parent 9592597 commit 5ffd1e7
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,7 @@ const _WebView = forwardRef<HandlerRef<WebView, WebViewProps>, WebViewProps>((pr
if (typeof nativeEventData === 'string') {
data = JSON.parse(nativeEventData)
}
} catch (e) {
data = {}
}
} catch (e) {}
const args = data.args
const postData: PayloadData = data.payload || {}
const params = Array.isArray(args) ? args : [postData]
Expand Down Expand Up @@ -190,6 +188,15 @@ const _WebView = forwardRef<HandlerRef<WebView, WebViewProps>, WebViewProps>((pr
})
webViewRef.current.postMessage(test)
}
}).catch((error: any) => {
if (webViewRef.current?.postMessage) {
const test = JSON.stringify({
type,
callbackId: data.callbackId,
error
})
webViewRef.current.postMessage(test)
}
})
}
const events = {}
Expand Down

0 comments on commit 5ffd1e7

Please sign in to comment.