Files
xhs-examples/xhs-mini-demos/api-case/webview/webview.js
2025-09-14 00:21:54 +08:00

38 lines
825 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
const { navigationBarTitleText } = require('./webview.json');
Page({
onShareAppMessage() {
return {
title: navigationBarTitleText,
path: '/api-case/webview/webview',
};
},
data: {
},
handleMessage(event) {
const detail = event.detail;
const data = detail.data || [];
console.log('====== 业务方 handleMessage ==>>>>>, ', event);
let content = '';
for (let i of data) {
if (typeof i === 'object') {
content += '类型object\n';
content += JSON.stringify(i);
} else {
content += '类型string\n';
content += i;
}
content += '\n';
content += '-----';
content += '\n';
}
xhs.showModal({
title: `接受到来自webview的${data.length}条消息`,
content: content
});
}
});