在微信小程序中循环遍历时怎么让索引加1

在微信小程序中循环遍历时怎么让索引加1,第1张

第一步,把要改变样式添加到相应js文件的全局变量中,如: data : { color : '#000' } 第二步,将变量绑定到view中,如: 第三步,在view中添加事件,如: bindtap="changeColor" 第四步,在相应js文件中添加该自定义方法: , changeColor: funct

讲解下循环输出元素

这里写描述

这里写描述

后台存储的数据给事

{

var local_database = [

{

date: "Sep 18 2016",

post_title:"冬日校花",

post_image: "/images/1jpg",

text: "美呀,美呀",

view_num: 112,

collect_num: 96,

turn_num: 515,

author_img: "/images/6jpg",

author:"高晴",

dateTime:"24小时",

detail:"我爱你,爱的如此深沉",

postId:0,

music:{

url: 'down/46993mp3',

title: "雪の华-南条爱乃",

coverImg: "/music/photo_new/T002R150x150M000001TEc6V0kjpVCjpgmax_age=2592000"

},

},

{

date: "Sep 18 2016",

post_title: "冬日校花",

post_image: "/images/2jpg",

text: "美呀,美呀",

view_num: 112,

collect_num: 96,

turn_num: 515,

author_img: "/images/6jpg",

author: "高晴",

dateTime: "24小时",

detail: "我爱你,爱的如此深沉",

postId: 1,

music: {

url: '/yq/5092537mp3',

title: "爱你-陈芳语",

coverImg: "/music/photo_new/T002R150x150M000001TEc6V0kjpVCjpgmax_age=2592000"

},

},

{

date: "Sep 18 2016",

post_title: "冬日校花",

post_image: "/images/3jpg",

text: "美呀,美呀",

view_num: 112,

collect_num: 96,

turn_num: 515,

author_img: "/images/6jpg",

author: "高晴",

dateTime: "24小时",

detail: "我爱你,爱的如此深沉",

postId: 2,

music: {

url: '/yq/204586755mp3',

title: "云烟成雨-房东的猫",

coverImg: "music/photo_new/T002R150x150M000001TEc6V0kjpVCjpgmax_age=2592000"

},

},

{

date: "Sep 18 2016",

post_title: "冬日校花",

post_image: "/images/4jpg",

text: "美呀,美呀",

view_num: 112,

collect_num: 96,

turn_num: 515,

author_img: "/images/6jpg",

author: "高晴",

dateTime: "24小时",

detail: "我爱你,爱的如此深沉",

postId: 3,

music: {

url: '/yq/213919334mp3',

title: "Your Song-Lady Gaga",

coverImg: ">

Page({

    data: {

        imgI:0

    }

})

loadImg(){

        let that=this,image=thatdatalistimg,i=thatdataimgI;

        for(i;i<imagelength;i++){

            wxdownloadFile({

                url: thatdataurl+image[i],

                success (res) {

                    if (resstatusCode === 200) {

                        wxsaveImageToPhotosAlbum({

                            filePath: restempFilePath,

                            success(res){

                                if (i==imagelength) {

                                    wxshowToast({

                                        title: '保存成功',

                                    })

                                } else {

                                    thatsetData({

                                        imgI:i+1

                                    })

                                    thatloadImg()

                                }

                            }

                        })

                    }

                }

            })

        }

    },

function getData()

{

return new Promise((resolve, reject)=>{

var arr = [];

var i=0,len = 3;

for(;i<len;i++)

{

//通过 request 向后台发送请求,把数据添加到 arr 数组里面,当长度相同时执行回调函数

request()then(res=>{

arrpush(res);

if(arrlength === len)resolve(arr);

})

}

});

}

getData()then(res=>{

consolelog(res);

})catch(res=>{

consolelog(res);

})

以上就是关于在微信小程序中循环遍历时怎么让索引加1全部的内容,包括:在微信小程序中循环遍历时怎么让索引加1、微信小程序这种json数据要怎么在前端循环输出{"0":{"day":"7","time_data":"数据"}}、微信小程序 for循环保存照片等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zz/9646031.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-30
下一篇 2023-04-30

发表评论

登录后才能评论

评论列表(0条)

保存