美文网首页
js-配置文件

js-配置文件

作者: 三米板 | 来源:发表于2020-04-05 00:53 被阅读0次

不想说话,直接上代码了:
建了一个config.js文件

var config = (function($){
    $.testConfig = {
        contextPath:'http://localhost:8080/test',
        maps:[
        {id:'map1',url:'*********'},
        {id:'map2',url:'*********'}
        ]
    };//这里的分号可带可不带
    
    $.api_result = {
        ok:     0 , 
        error:  1,
    };//这里的分号可带可不带
    $.name ='liuguoyan';//这里的分号可带可不带
    $.school = '河北师大';//这里的分号可带可不带
    return $;
    })(window.config||{});

下面是我的使用方法:

console.log(config.school) ;
console.log(config.testConfig.contextPath) ;
console.log(config.api_result.ok) ; 

再下面是我的打印结果:

河北师大
http://localhost:8080/test
0

maps我没有用,一般也使用不到这个格式的配置文件,所以忽略了。

相关文章

网友评论

      本文标题:js-配置文件

      本文链接:https://www.haomeiwen.com/subject/prgephtx.html