微信扫码登录

其他登录方式

绑定手机号

注册

我同意用户协议

忘记密码

用户协议

绑定手机号

近期有不法分子打着爱盈利的旗号,制作“爱盈利”名称的App,并伪造爱盈利证件,骗取用户信任,以抖音点赞赚钱或其他方式赚钱为名义,过程中以升级会员获得高佣金为名让用户充值。
爱盈利公司郑重声明:我司没有研发或运营过任何名为“爱盈利”的APP,我司做任务赚钱类产品从没有让任何普通用户充值升级会员。我公司产品均在本网站可查询,请将网站拉至底部,点击“关于我们”可查看爱盈利相关产品与服务。
温馨提示:当遇到此类问题请拨打官方电话或添加官方微信,以免财产损失。爱盈利官网地址:www.aiyingli.com。
  • 推广与合作
X

小程序丨wx:for列表循环+模板,如何修改模板中的图片

来源: 3173

服务器返回输入如下:

{"index":"1","face":"../images/a.png","name":"张三","age":"18"}


JS 代码如下:


Page({

  data: {

    ulist:[]

  },

onLoad: function () {

    var that = this

    var utoken = wx.getStorageSync("utoken")

      wx.request({

        url: 'https://qq.com/WX/userlist.php',

        data: {

          utoken: utoken

        },

        success: function (res) {

          that.setData({

            ulist: res.data

          })

        }

      })

},

  Play:function(e){

    var that=this

    var ind = e.currentTarget.dataset.id

    var voc = that.data.ulist[ind-1].face

    console.log(voc)

  }

})


Wxml代码如下:

<view class="xslist">

  <block wx:for="{{ulist}}" wx:key="name">

    <template is="userlista" data="{{item}}" />

  </block>

</view>


<template name="userlista">

      <view class="list-text">{{item.name}} </view>

      <view class="list-text">{{item.age}} </view>

      <view class="list-youimg">

        <image data-id="{{item.index}}" class="list-img" src="{{item.face}}" bindtap="Play"></image>

      </view>

</template>


问题是,在Play事件中,如何更改image中的图片?

网友回复:

迷***:
var list = this.data.ulist
 
// 修改第一个图片
list[0].image = './new-image.jpg'
 
this.setData({ulist: list})


(***:

完美!非常感谢!

爱盈利(aiyingli.com)移动互联网最具影响力的盈利指导网站。定位于服务移动互联网创业者,移动盈利指导。我们的目标是让盈利目标清晰可见!降低门槛,让缺乏经验、资金有限的个人和团队获得经验和机会,提高热情,激发产品。

评论

相关文章推荐

SELECT dw_posts.ID,dw_posts.post_title,dw_posts.post_content FROM dw_posts INNER JOIN dw_term_relationships ON (dw_posts.ID = dw_term_relationships.object_id) WHERE 1=1 AND(dw_term_relationships.term_taxonomy_id = 5246 ) AND dw_posts.post_type = 'post' AND (dw_posts.post_status = 'publish') GROUP BY dw_posts.ID ORDER BY RAND() LIMIT 0, 6

京ICP备15063977号-2 © 2012-2018 aiyingli.com. All Rights Reserved. 京公网安备 11010102003938号