gun.json文件代码:
{
"Gun_class":[
"栓动式狙击枪",
"射手步枪",
"突击步枪",
"冲锋枪"
],
"Bolt-on-sniper-rifle":[
{
"name":"AWM",
"box_magazine":"10",
"bullet":".300马格南步枪弹",
"caliber":"7.62mm",
"weight":"6.5kg (不含弹匣)"
},
{
"name":"M24",
"box_magazine":"5",
"bullet":"M118特种弹",
"caliber":"7.62mm",
"weight":"5.4kg(不带瞄准镜)"
},
{
"name":"Kar98",
"box_magazine":"5",
"bullet":"7.92×57mm步枪弹",
"caliber":"7.92mm",
"weight":"3.9kg (无弹药装填)"
}
],
"sniper-rifle":[
{
"name":"MINI14",
"box_magazine":"5,20,30",
"bullet":"M193式5.56×45,mm和SS109式5.56×45,mm枪弹",
"caliber":"5.56mm",
"weight":"全枪质量(不含弹匣)----2.9kg"
},
{
"name":"SKS",
"box_magazine":"10",
"bullet":" 7.62×39mm",
"caliber":"7.62mm",
"weight":"未知"
},
{
"name":"SLR",
"box_magazine":"30",
"bullet":"SS109式5.56×45,mm枪弹",
"caliber":"5.56mm",
"weight":"步兵型----4.325kg"
},
{
"name":"MK14",
"box_magazine":"20",
"bullet":"7.62mm",
"caliber":"7.62mm",
"weight":"5.1kg"
}
]
}
gun.js文件代码片段
var header = document.querySelector(‘header‘);
var section = document.querySelector(‘section‘);
var requestURL = ‘https://raw.githubusercontent.com/wusifan19980908/cdu.edu/master/gun.json‘;
var request = new XMLHttpRequest();
request.open(‘GET‘, requestURL);
request.responseType = ‘json‘;
request.send();
var Guns ;
request.onload = function () {
Guns = request.response;
setHeader();
setGuns();
}
远端json代码:https://github.com/wusifan19980908/cdu.edu/blob/master/gun.json