ajax request json array base64-encrypted and output through the v-for traversal of vue

        .ajax $ ({ 
            type: 'GET' , 
            dataType: 'JSON' , 
            URL: '/Template/xpshop_currents/inc/imgUrl.json' , 
            Cache: to false , 
            Success: function (Data) { 
          //window.atob () base64 decoding, Escape encoding, decoding decodeURIComponent, Chinese here in order to solve the problem of distortion base64 decoding the let to SPDAT
= decodeURIComponent (Escape (window.atob (Data [0 ]))); the let PAT1 ? = /\[(.*) ] / ; the let PAT2 = /}, / G; the let PAT3 = /; / ;
          // Because it becomes a string of json string array encryption, so the json data with another array wrapped encrypted string, or json resources can not be loaded, where the first string extracted by being put pat1 of the let SP
= spdata.split (PAT1) [0 ;]
          segmentation of the array element replacement // comma semicolon, so easy under the let spp
= sp.replace (PAT2, '};' ); the let ImgUrlArrOld = spp.split (PAT3 ); // generates a random array of the let ImgUrlArr = new new the array (); the while (ImgUrlArr.length < ImgUrlArrOld.length) { the let NUM = ImgUrlArrOld [Math.floor (Math.random () * ImgUrlArrOld.length)]; the let numObject = JSON.parse(num); if (ImgUrlArr.indexOf(numObject)<0) { ImgUrlArr.push(numObject); } } let vm = new Vue({ el:'#appVue', data:{ src:ImgUrlArr, backgroundRepeat: 'no-repeat', backgroundPosition: 'center', backgroundSize: '100% 100%', }, // 加载函数 Methods: { ImgInfiniteRolling: function () { ImgInfiniteRolling ( -200,1 ) }, }, // after the page has loaded a template function calls Mounted () { the this .ImgInfiniteRolling () } }) } })
    function ImgInfiniteRolling (the begin, Speed ) {
      the console.log (the begin, Speed);
    }

 

Guess you like

Origin www.cnblogs.com/webwangjie/p/11331092.html