0
在我的ios应用程序中,我使用WKWebview.evaluateJavaScript()来执行javascript以获取div boundingRect。在我的网页上,我用anjularjs渲染我的网页的一部分,该网页的内容是,swift如何在anjular渲染页面后执行javascript?
<body ng-app="home" ng-controller="HomeController" style="min-height:700px;">
<printerinfo></printerinfo>
</body>
<div id="movie" style="border: 1px grey dotted; width: 120px; height: 90px;"></div>
迅速
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
self.wk.evaluateJavaScript("var rect = document.getElementById('movie').getBoundingClientRect(); [rect.x, rect.y, rect.width, rect.height, rect.top, rect.right, rect.bottom, rect.left];") { (result, error) -> Void in
print(result)
}
}
从结果,
Optional(<__NSArrayM 0x170251010>(
<null>,
<null>,
120,
90,
0,
120,
90,
0
)
)
的boundingRect是视口的起源,看起来身体在视口中没有空间。我认为这是因为当网页加载时,angualrjs没有呈现身体部分。
那么如何在anjularjs使用swift3渲染页面后执行javascript?
非常感谢。
查看本帖回复http://stackoverflow.com/a/43672099/6521116 http://stackoverflow.com/q/28149097/6521116 –