tns信息= 5.1.1
只有在ios中工作时,才在webview中上传文件不适用于android.I尝试了一些xmlit的工作。但是,当我进入文件上传内部时,浏览器将永远无法工作。
我真的已经尝试过所有代码,请在这里为我提供帮助。
最近几天以来一直在努力从WebView上载文件,并且没有任何进展。我在Google上搜索并实施了所有建议的解决方案,但均无用,例如:建议的解决方案等等。
<WebView src="https://fxo.io/m/d6r4bjve" row="1" loaded="onWebViewLoaded" id="myWebView" style="width:100%; height:100%;"></WebView>
我尝试了一些代码,但是没有用.......
const ChatViewModel = require("./chat-model");
const view = require("tns-core-modules/ui/core/view");
const switchModule = require("tns-core-modules/ui/switch");
const config = require("./config");
const httpModule = require("http");
const WebView = require("tns-core-modules/ui/web-view").WebView;
const webViewModule = require("tns-core-modules/ui/web-view");
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var MyWebChromeClient = /** @class */ (function (_super) {
__extends(MyWebChromeClient, _super);
function MyWebChromeClient() {
alert("this");
var _this = _super.call(this) || this;
return global.__native(_this);
}
MyWebChromeClient.prototype.onStop = function(){
console.log("this");
}
MyWebChromeClient.prototype.onProgressChanged=function( view, newProgress) {
console.log(newProgress);
}
MyWebChromeClient.prototype.onCreateWindow=function( view, isDialog, isUserGesture, resultMsg){
console.log("working");
}
MyWebChromeClient.prototype.onShowCustomView = function (view, callback) {
// _super.prototype.onShowCustomView.call(this);
// Store the view and its callback for later (to kill it properly)
// if(this.mCustomView != null){
callback.onCustomViewHidden(); //return;
config.Navigate("home/v",webargs,url);
// }
// this.mCustomView = view;
// webview.android.setVisibility(View.GONE);
// customViewContainer.CustomLayoutView(view);
//this.mCustomViewCallback = callback;
console.log('fullscreen');
};
MyWebChromeClient.prototype.onHideCustomView = function () {
console.log("this2");
_super.prototype.onHideCustomView.call(this);
_super.prototype.mCustomView = null;
};
return MyWebChromeClient;
}(android.webkit.WebChromeClient));
var LayoutInflater = android.view.LayoutInflater;
var View = android.view.View;
var mCustomView ;//= android.view.View;
var WebChromeClient = android.webkit.WebChromeClient;
var WebViewClient = android.webkit.WebViewClient;
function onWebViewLoaded(webargs) {
alert("working now");
const page = webargs.object.page;
const vm = page.bindingContext;
const webview = webargs.object;
vm.set("result", "WebView is still loading...");
vm.set("enabled", false);
webview.on(webViewModule.WebView.loadFinishedEvent, (args) => {
let message = "";
if (!args.error) {
message = `WebView finished loading of ${args.url}`;
} else {
message = `Error loading ${args.url} : ${args.error}`;
}
vm.set("result", message);
console.log(`WebView message - ${message}`);
});
webview.android.getSettings().setJavaScriptEnabled(true);
webview.android.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
webview.android.getSettings().setSupportZoom(false);
webview.android.getSettings().setAllowFileAccess(true);
webview.android.getSettings().setAllowContentAccess(true);
webview.android.getSettings().setAppCacheEnabled(true);
webview.android.getSettings().setBuiltInZoomControls(true);
webview.android.getSettings().setDisplayZoomControls(true);
webview.android.getSettings().setSaveFormData(true);
let myWebChromeClient = new MyWebChromeClient();
webview.android.setWebChromeClient(myWebChromeClient);
// console.log("1=====================url",url);
webview.android.loadUrl("https://fxo.io/m/d6r4bjve");
}
exports.onWebViewLoaded = onWebViewLoaded;