他のjsファイルで導入されたJSコード

1  / * **引入JS文件
 2             @example:インポート( 'JS / aui.picker.js')
 3             @example:インポート([ 'JS / aui.picker.js'、 'CSS / aui.picker.css' 】)
 4          * / 
5          機能インポート(URL){    
 6つ             のvar _this = この;
7              スイッチ(url.constructor){
 8                  ケース配列:
 9                      のための(url.entriesのCONST [インデックス、項目()){
 10                          レコード生成(アイテム)
11                      }
 12                      ブレーク13                  ケース文字列:
 14                     レコード生成(URL);
15                      休憩;
16                  デフォルト17                      休憩18              }
 19              関数レコード生成(ファイル){
 20                  であれば(/^.+?\.js$/ .TEST(ファイル))
 21                  { // JS文件引入
22                      VARのスクリプト=のdocument.createElement( "スクリプト" )。
23                      script.setAttribute( "タイプ"、 "テキスト/ javascriptの" );
24                      script.setAttribute( "SRC" ファイル);
25                      document.querySelector( '頭').appendChild(スクリプト)。
26                  }
 27                  であれば(/^.+?\.css$/ .TEST(ファイル))
 28                  { // CSS文件引入
29                      VAR CSS =のdocument.createElement( 'リンク' )。
30                      css.rel = 'スタイルシート' 31                      css.type = 'テキスト/ CSS' ;
32                      css.href = ファイル。        
33                      document.querySelector( 'ヘッド' ).appendChild(CSS)。    
34                  }            
 35              }
 36          }

おすすめ

転載: www.cnblogs.com/aui-js/p/12144946.html