标签:private event proxy tin boolean lov str this star
import { ModelClass } from "engine/injector/Injector";
import { Inject } from "core/injector/Injector";
import { environment } from "engine/env/Environment";
@ModelClass
export class ExerciseProxy {
private polyfill_suffix : string = "/s17/lib/polyfill/polyfill.min.js" ;
private vue_suffix : string = "/s17/lib/vue/2.2.5/vue.min.js" ;
private vuex_suffix : string = "/s17/lib/vue/plugin/vuex/2.2.1/vuex.min.js" ;
private venus_js_suffix : string = "/s17/lib/venus/2.5.1/venus.min.js" ;
private venus_css_suffix : string = "/s17/lib/venus/2.5.1/css/venus.min.css" ;
private initialized : boolean = false ;
public startInitialize( completeCbk: ( ) => void): void
{
if ( this.initialized ) {
setTimeout( function () {
completeCbk( ) ;
}, 0 ) ;
}
let __promise = window["Promise"] ;
let env: string = environment.env ;
let promise = new __promise( ( resolove, reject ) => {
let script = document.createElement("script") ;
script.type = ‘text/javascript‘;
document.head.appendChild( script ) ;
let url = environment.toCDNHostURL(this.polyfill_suffix, false, false) ;
script.onload = function ( evt: Event ): void {
resolove("polyfill success") ;
} ;
script.src = url ;
} ) ;
promise.then( (data: string) => {
let promise = new __promise( ( resolove, reject ) => {
let script = document.createElement("script") ;
script.type = ‘text/javascript‘;
document.head.appendChild( script ) ;
let url = environment.toCDNHostURL(this.vue_suffix, false, false) ;
script.onload = function ( evt: Event ): void {
resolove("vue success") ;
} ;
script.src = url ;
} ) ;
return promise ;
} ).then( (data: string) => {
let promise = new __promise( ( resolove, reject ) => {
let script = document.createElement("script") ;
script.type = ‘text/javascript‘;
document.head.appendChild( script ) ;
let url = environment.toCDNHostURL(this.vuex_suffix, false, false) ;
script.onload = function ( evt: Event ): void {
resolove("vuex success") ;
} ;
script.src = url ;
} ) ;
return promise ;
} ).then( (data: string) => {
let promise = new __promise( ( resolove, reject ) => {
let script = document.createElement("script") ;
script.type = ‘text/javascript‘;
document.head.appendChild( script ) ;
let url = environment.toCDNHostURL(this.venus_js_suffix, false, false) ;
script.onload = function ( evt: Event ): void {
resolove("venus_js success") ;
completeCbk( ) ;
} ;
script.src = url ;
} ) ;
return promise ;
} ).then( (data: string) => {
let promise = new __promise( ( resolove, reject ) => {
let link = document.createElement(‘link‘);
link.rel = ‘stylesheet‘;
link.type = ‘text/css‘;
document.head.appendChild( link ) ;
let url = environment.toCDNHostURL(this.venus_css_suffix, false, false) ;
link.onload = function ( evt: Event ): void {
resolove("venus_css success") ;
completeCbk( ) ;
} ;
link.href = url ;
} ) ;
return promise ;
} ) ;
}
}
Promise 练习
标签:private event proxy tin boolean lov str this star
原文地址:https://www.cnblogs.com/jason-beijing/p/10327451.html