如何在Cocos Creator中通过.js在WebView中打开URL

时间:2018-11-28 12:37:42

标签: cocos2d-x cocos2d-js cocoscreator

我想打开任何这样的网址(https://example.com/mPayment/api.php?playerid=name&method=init) 在WebView中通过脚本编码而不是从CocosCreator的设计视图中获取。 我已经完成了这段代码,但是没有打开我做错的事情,

var url =  "https://example.com/mPayment/api.php?playerid=name&method=init";
        this.webPage._url = url;
        console.log("Webview1111111  ==== ", this.webPage._url);

在url上有我要传递玩家ID的名称。 我想在我的cocos创作者游戏中实现Payment网关。

1 个答案:

答案 0 :(得分:1)

工作正常:

import { BrowserModule } from '@angular/platform-browser';
import { NgModule, Injector, ErrorHandler } from '@angular/core';
import { HttpModule } from '@angular/http';
import { HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { AppInjector } from 'app/appinjector.module';
import { AdminModule } from 'app/admin/admin.module';
import { HttpInterceptorModule } from './interceptors/http-interceptor.module';
import { AuthRequiredGuard } from 'app/guards/auth-required.guard';
import { ErrorsComponent } from './errors/errors.component';
import { CustomErrorHandler } from './custom-error-handler';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    BrowserAnimationsModule,
    HttpClientModule,
    HttpModule,
    AppRoutingModule,
    AdminModule
  ],
  providers: [
    AuthRequiredGuard,
    {
      provide: ErrorHandler,
      useClass: CustomErrorHandler
    }
  ],
  bootstrap: [AppComponent]
})
export class AppModule {
  constructor(injector: Injector) {
    AppInjector.setInjector(injector);
  }
}

也许您忘记了将webView绑定到设计器中的UI元素。