Skip to content

Commit 45bad6b

Browse files
committed
优化include
1 parent e02a607 commit 45bad6b

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

dist/mbgl-include.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
var css = '<link rel="stylesheet" href="' + url + '">';
2020
document.writeln(css);
2121
}
22-
Array.prototype.contains = function ( needle ) {
23-
for (i in this) {
24-
if (this[i] == needle){
22+
function inArray(arr,item){
23+
for (i in arr) {
24+
if (arr[i] == item){
2525
return true;
2626
}
2727
}
@@ -31,21 +31,21 @@
3131
function load() {
3232
var includes=(targetScript.getAttribute('include')||"").split(",");
3333
var excludes=(targetScript.getAttribute('exclude')||"").split(",");
34-
if(!excludes.contains('mapbox-gl')) {
34+
if(!inArray(excludes,'mapbox-gl')) {
3535
inputCSS("https://cdn.bootcss.com/mapbox-gl/0.39.1/mapbox-gl.css");
3636
inputScript("https://cdn.bootcss.com/mapbox-gl/0.39.1/mapbox-gl.js");
3737
}
38-
if(includes.contains('mapv')){
38+
if(inArray(includes,'mapv')){
3939
inputScript("http://mapv.baidu.com/build/mapv.min.js");
4040
}
41-
if(!excludes.contains('iclient9-mapboxgl')) {
41+
if(!inArray(excludes,'iclient9-mapboxgl')) {
4242
inputScript("../../dist/iclient9-mapboxgl.min.js");
4343
}
44-
if(includes.contains('echarts')){
44+
if(inArray(includes,'echarts')){
4545
inputScript("http://cdn.bootcss.com/echarts/3.6.2/echarts.min.js");
4646
inputScript("http://iclient.supermapol.com/libs/echartsLayer/EchartsLayer.js");
4747
}
48-
if(includes.contains('proj4')){
48+
if(inArray(includes,'proj4')){
4949
inputScript("https://cdn.bootcss.com/proj4js/2.4.3/proj4.js");
5050
}
5151
}

0 commit comments

Comments
 (0)