测试本地翻译文件,格式正不正确,检查JSON格式
- 可以一部分
str_info_english1.js
,一部分的检查,是否报错
<script>
function foo() {
var formData = new FormData();
//提交表单
var xhr = new XMLHttpRequest();
xhr.open('GET', '/str_info_english1.js', true);
xhr.setRequestHeader('content-type', 'application/json; charset=UTF-8');
xhr.onreadystatechange = function () {
// console.log(xhr.response);
var data = xhr.response;
sessionStorage.setItem('language', data)
}
xhr.send(formData);
}
foo();
function get() {
var data = sessionStorage.getItem('language');
data1 = JSON.parse(data);
console.log(data1.abc,typeof(data1));
console.log({abc:2222});
}
setTimeout(() => {
get();
}, 1000);
</script>
标签:翻译,console,log,sessionStorage,xhr,var,存到,data
From: https://www.cnblogs.com/yaopaoa/p/17563659.html