123456789101112131415161718192021222324252627282930313233343536373839404142 |
- var CustomerWebView = cc.Class({
- extends: cc.WebView,
- onEnable: function(){
- let impl = this._impl;
- if (!CC_EDITOR) {
- impl.setVisible(true);
- } else {
- this.loadURL(this._url);
- }
- },
- /**
- * 加载URL,完成加载后显示
- * @param url
- * @param loaded 加载完成回调
- * @param loading 加载中回调
- * @param loadError 加载错误回调
- */
- loadURL: function(url, loaded, loading, loadError) {
- let impl = this._impl;
- this._url = url;
- impl.createDomElementIfNeeded(this.node.width, this.node.height);
- if (!CC_EDITOR) {
- var onLoaded = function(...args) {
- (loaded) ? loaded.call(this, ...args) : this._onWebViewLoaded.call(this, ...args);
- impl.setVisible(true);
- }
- impl.setEventListener(CustomerWebView.EventType.LOADED, onLoaded.bind(this));
- impl.setEventListener(CustomerWebView.EventType.LOADING, (loading) ? loading.bind(this) : this._onWebViewLoading.bind(this));
- impl.setEventListener(CustomerWebView.EventType.ERROR, (loadError) ? loadError.bind(this) : this._onWebViewLoadError.bind(this));
- } else {
- impl.setVisible(true);
- }
- impl.loadURL(url);
- }
- });
- module.exports = cc.CustomerWebView = CustomerWebView;
|