【问题标题】:How to use WKWebView with local file in appcelerator Titanium?如何在 appcelerator Titanium 中将 WKWebView 与本地文件一起使用?
【发布时间】:2021-02-03 19:38:08
【问题描述】:

我尝试将新的 WKWebview 与 appcelerator 的本地 URL 一起使用

var WK = require('ti.wkwebview');

var webview = WK.createWebView({
    url:'about.html',
});

win.add(webview);

我的about.html文件在根目录下,HTML代码是:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Test Page</title>
</head>

<body style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:14px">
<p align="center"><img src="images/DefaultIcon.png" alt="" width="50" height="50" border="0"></p>
<p align="center"><b>Text to test thanks</p>
<br/>
</html>

但是页面没有显示。我不明白为什么。有什么想法吗?

【问题讨论】:

  • 丹,你为什么还在用这个?我正要向您展示如何加载本地 HTML,但后来意识到您使用的是此模块而不是内置的默认 WebView 组件。从 SDK 8.0.0.GA 开始,WKWebView 被用作默认的 WebView 组件。因此,如果您使用的是 SDK 8.0.0.GA 或更高版本,您可以在 Classic 上使用 Ti.UI.createWebView() 或在 Alloy 上使用 ,您可以删除 WKWebView 模块。
  • @Newport99 你现在必须在 iOS 上使用 WKWebView。 UIWEbView 不再被接受:itms 90809
  • Dan 我们在说同样的事情......除了模块在 2 年内没有更新 - 停止尝试使用它。使用 Titanium SDK 8.0.0,我们现在使用 WKWebView 来实现 Ti.UI.WebView(因为 Apple 已弃用 UIWebView)。 docs.appcelerator.com/platform/latest/#!/api/…
  • 取决于内容:只使用原生元素,而不是 web 视图

标签: javascript appcelerator appcelerator-titanium appcelerator-mobile


【解决方案1】:

url 属性在引用本地 Web 内容时使用的路径是相对于 Titanium 项目的项目 Resources 目录或 Alloy 项目的 app/assets 和 app/lib 目录的。

Using Local Web Content with WebView

【讨论】:

    猜你喜欢
    • 2016-03-06
    • 2012-09-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-31
    • 2013-07-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多