UNPKG

tool_bluej_webpack

Version:

支持最新的webpack3.4.1打包 适用于单页应用、多页应用或vue应用 > **必须保留原始目录结构,千万不要删除任何的文件夹**

144 lines (130 loc) 3.09 kB
/** *单页应用的入口文件 */ import "../scss/test.scss"; /****测试ES2015*****/ // function test(a,b,c){ // alert(a+b+c); // } // const arr = [1,2,3]; // test(...arr); // // // new Promise((resolve, reject) =>{ // // console.log("执行第一步"); // resolve("第一步结果"); // // }).then(res=>{ // console.log("执行第二步"); // fetch("./static/test.json").then((res)=>{console.log(res);return "第二步结果"}); // }).then(res=>{ // console.log("执行第三步"); // // throw new Error("故意报错"); // }).catch(error=>{ // alert(error); // }) //async function step1(){ // console.log("执行第一步"); // return fetch("./static/test.json").then((res)=>{console.log(res);return res}); //} // //async function test(){ // return setTimeout(()=>{ // console.log("fuck"); // return "aaa"; // },2000) //} //async function step2(res){ // console.log("执行第二步"); // return await test(); // // return setTimeout(()=>{ // // console.log("rinima"); // // return new Promise((resolve, reject) =>{resolve()}) // // },2000); //} //async function step3(){ // console.log("执行第三步"); // return "第三步结果"; //} //async function liucheng(){ //var step11 = await step1(); //var step22 = await step2(step11); //var step33 = await step3(); //// console.log(step11,step22,step33); //} //liucheng(); /****测试ES2016*****/ // alert(2**2); // // /****测试ES2017*****/ // async function asyncFunc() { // const result = await otherAsyncFunc(); // alert("我后执行,返回"+result); // } // // async function otherAsyncFunc() { // alert("我先执行"); // return "bgg"; // } // asyncFunc(); //var p = new Promise((reslove,reject)=>{ // reslove(); //}) //p.then(res=>{ // return new Promise((reslove,reject)=>{ // alert("11111"); // setTimeout(reslove,3000) // }) //}).then(res=>{ // return new Promise((reslove,reject)=>{ // alert("22222"); // setTimeout(reslove,2000) // }) //}) // //var s22 =step2() ; // async function step1(){ // console.log(111111); // var s2 = await s22; // var s3 = await step3(); // console.log(s2,s3); //} //async function step2(){ //// setTimeout(()=>{ //// console.log("222222"); //// return Promise.resolve(); //// },2000) // var img = new Image(); // img.onload= ()=>{ // // document.body.appendChild(img) // return 22222; // } // img.src="../images/logo.png" //} //async function step3(){ //// return fetch("./static/test.json").then(res=>{ //// console.log(333333); //// console.log(res); //// }); // return 33333; //} // //step1(); async function getFetch(url){ return fetch(url).then(function(response) { return response.json(); }).then(function(data) { return data; }).catch(function(e) { console.log("Oops, error"); }); } async function gogo(){ var res1 = await getFetch("../static/test.json"); var res2 = await getFetch("../static/test.json"); // console.log(res1.then(res=>{alert(res)}),res2); console.log(res1,res2); } gogo();