var relativePath = '_www/tab-webview-subpage-index.html';
var localPath = plus.io.convertLocalFileSystemURL(relativePath);
// 补全协议头(兼容模拟器/真机)
if (!localPath.startsWith('file://')) {
localPath = 'file://' + localPath;
}
console.log('最终访问路径:', localPath); // 真机日志确认路径是 file:///apps/H50849CDF/www/...
plus.webview.getWebviewById('tab-webview-subpage-index.html').loadURL(localPath);
plus.webview.getWebviewById('tab-webview-subpage-index.html').show();
这段代码在 真机调试模式就没问题。可以正常打开 tab-webview-subpage-index.html 页面,并且打印日志
最终访问路径: file:///storage/emulated/0/Android/data/io.dcloud.HBuilder/apps/HBuilder/www/tab-webview-subpage-index.html at index.html:220
打包之后,就变成了We are sorry
请求页面file:///apps/xxxxxxx/www/tab-webview-subpage-index.html 无法打开
1 个回复
爱豆豆 - 办法总比困难多
真机下是私有目录 不加file:// 直接用'_www/tab-webview-subpage-index.html'试试