首页 > 解决方案 > 如何在 appcelerator Titanium 中将 WKWebView 与本地文件一起使用?

问题描述

我尝试将新的 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>

但是页面不显示。我不明白为什么。任何想法 ?

标签: javascriptappceleratorappcelerator-titaniumappcelerator-mobile

解决方案


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

通过 WebView 使用本地 Web 内容


推荐阅读