【发布时间】:2021-04-27 22:19:54
【问题描述】:
我正在尝试使用 swift 参数加载 html 字符串,但它没有加载
let htmlStr = """
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src= "'\(jsUrl)'" id="xxxxx"
data-error="ErrorCallback" data-cancel="CancelCallback" data-complete="CompleteCallback"
data-timeout="TimeoutCallback">
</script>
</head>
<body>
<div style="clear: both;height: 3px;">
</div>
</body>
<script type="text/javascript">
CheckoutConfigure();
Checkout.showLightbox();
function CancelCallback() {
AndroidFunction.cancelCallback()
}
function ErrorCallback(response) {
AndroidFunction.errorCallback(JSON.stringify(response))
}
function CompleteCallback(response,sessionVersion) {
AndroidFunction.completeCallback(response, sessionVersion)
}
function TimeoutCallback() {
AndroidFunction.timeoutCallback()
}
</script>
</html>
"""
这里是调用函数
webView.loadHTMLString(htmlStr, baseURL: nil)
【问题讨论】:
-
“未加载”是什么意思?
-
我看到空白的 webview.@matt
-
为什么会是非空白的?
-
@matt android 中的相同代码正在 webview 中加载
-
即使在 Safari 和 Chrome 中,此 HTML 文件也会导致网页空白。