gpt4 book ai didi

ios - Nativescript + iOS webview + 本地文件

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:11:48 25 4
gpt4 key购买 nike

我目前正在开发一个简单的应用程序,它有一个使用 WebView 的 HTML 部分。

内容在 app/www 文件夹中,我从“home.ts”组件访问它们,在 HTML 中有类似的内容

<GridLayout
class="main-layout"
columns="*"
rows="*"
>
<WebView
src="~/www/index.html"
class="web-view"
col="0"
id="wv"
row="0"
></WebView>
</GridLayout>

这个文件使用了一些图片、一些 JS 和一些 CSS。

它在 Android 上运行良好,但我无法使其在 iOS 上运行。哦,它在 iOS 模拟器上运行良好,但在实际设备上却不行(我目前有一个 iOS 9 iPod touch 用于测试这些东西)。

我在 Info.plist 上配置了正确的 key (它与 URL 一起使用 https://www.google.com ),我认为我没有做任何奇怪的事情。

这是我的 package.json

{
"description": "WebView App",
"license": "LicenseRef-LICENSE",
"readme": "README",
"nativescript": {
"id": "com.app.name"
},
"dependencies": {
"@angular/animations": "~4.1.0",
"@angular/common": "~4.1.0",
"@angular/compiler": "~4.1.0",
"@angular/core": "~4.1.0",
"@angular/forms": "~4.1.0",
"@angular/http": "~4.1.0",
"@angular/platform-browser": "~4.1.0",
"@angular/router": "~4.1.0",
"nativescript-angular": "~3.0.0",
"nativescript-theme-core": "~1.0.2",
"reflect-metadata": "~0.1.8",
"rxjs": "~5.3.0",
"tns-core-modules": "^3.0.1",
"zone.js": "~0.8.2"
},
"devDependencies": {
"@angular/compiler-cli": "~4.1.0",
"babel-traverse": "6.24.1",
"babel-types": "6.24.1",
"babylon": "6.17.1",
"copy-webpack-plugin": "~4.0.1",
"lazy": "1.0.11",
"nativescript-css-loader": "~0.26.0",
"nativescript-dev-typescript": "~0.4.0",
"raw-loader": "~0.5.1",
"resolve-url-loader": "~2.0.2",
"tns-platform-declarations": "^3.0.0-rc.2",
"typescript": "~2.2.1"
}
}

最佳答案

这是本地页面的一个已知错误,它无法确定 ~ 在文件系统方面的含义您需要更改代码中的 src 并弄清楚 ~ 指的是什么。

使用:

import * as fs from "tns-core-modules/file-system";
public webViewSRC: string = encodeURI(`${fs.knownFolders.currentApp().path}/www/index.html`);

看到这个问题:

https://github.com/NativeScript/NativeScript/issues/4443

关于ios - Nativescript + iOS webview + 本地文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44505825/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com