我正在尝试使用 SwiftUI 读取 HTML 格式的内容,我尝试使用几种不同的方法来加载 HTML 字符串,但该字符串没有显示。我正在使用 XCode 11.2.1,非常感谢您的帮助。
import SwiftUI
import Combine
import WebKit
struct SubChapterDetails: View {
let sentDescription: String
let webView = WKWebView()
var body: some View {
VStack {
Text("Testing HTML Content")
Spacer()
HTMLStringView(htmlContent: "<h1>This is HTML String</h1>") //It doesn't displays this when the code is executed
Spacer()
}
}
}
struct SubChapterDetails_Previews: PreviewProvider {
static var previews: some View {
SubChapterDetails(sentDescription: "")
}
}
struct HTMLStringView: UIViewRepresentable {
let htmlContent: String
func makeUIView(context: …Run Code Online (Sandbox Code Playgroud)