mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 03:31:45 +08:00
src property added
This commit is contained in:
@ -1,5 +1,7 @@
|
||||
import common = require("ui/web-view/web-view-common");
|
||||
import trace = require("trace");
|
||||
import utils = require("utils/utils");
|
||||
import fs = require("file-system");
|
||||
|
||||
declare var exports;
|
||||
require("utils/module-merge").merge(common, exports);
|
||||
@ -74,6 +76,30 @@ export class WebView extends common.WebView {
|
||||
this._android.loadUrl(url);
|
||||
}
|
||||
|
||||
public _loadSrc(src: string) {
|
||||
trace.write("WebView._loadSrc(" + src + ")", trace.categories.Debug);
|
||||
|
||||
this._android.stopLoading();
|
||||
|
||||
if (utils.isFileOrResourcePath(src)) {
|
||||
|
||||
if (src.indexOf("~/") === 0) {
|
||||
src = fs.path.join(fs.knownFolders.currentApp().path, src.replace("~/", ""));
|
||||
}
|
||||
|
||||
var file = fs.File.fromPath(src);
|
||||
if (file) {
|
||||
file.readText().then((r) => {
|
||||
this._android.loadData(r, "text/html", null);
|
||||
});
|
||||
}
|
||||
} else if (src.indexOf("http://") === 0 || src.indexOf("https://") === 0) {
|
||||
this._android.loadUrl(src);
|
||||
} else {
|
||||
this._android.loadData(src, "text/html", null);
|
||||
}
|
||||
}
|
||||
|
||||
get canGoBack(): boolean {
|
||||
return this._android.canGoBack();
|
||||
}
|
||||
|
Reference in New Issue
Block a user