jsonHttp() {
var that = this;
//(1).实例化ajax对象
let xhr = new XMLHttpRequest();
//(2).设置请求方法和地址
//get请求的数据直接添加在url的后面 格式是 url?key=value
xhr.open(
"get",
"https://cdn. 在线JSON文件地址.json"
);
//(3).发送请求
xhr.send();
//(4).注册回调函数
xhr.onload = function () {
// console.log(xhr.responseText,'responseText')
that.options = JSON.parse(xhr.responseText);
};
},
但是呢 有个弊端 频繁的动options中的 json数据 会造成 里面的数据有更改
这个bug老久前遇到 那时忘记记载了 现在重现不出来