日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

微信小程序 setData动态设置数组中的数据

發布時間:2024/4/30 编程问答 38 豆豆
生活随笔 收集整理的這篇文章主要介紹了 微信小程序 setData动态设置数组中的数据 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

現在有一組死數據

但是想在使用時動態修改其中的值

在setData中不能直接設置,真想。。。。。。,算了是這個和諧的社會救了那個工程師。


接下來,我們去征服她!

死數據:

//地圖上方控件controls: [{id: 1,iconPath: '../image/jiuyuan.png',position: {left: 85,top: 450-50,width: 70,height: 50},clickable: true},{id: 2,iconPath: '../image/jiuzhu.png',position: {left:165,top: 450 - 50,width: 70,height: 50},clickable: true},],我的設計初衷是讓這兩個圖標始終在手機屏幕距離頂部85%的位置

所以我需要在獲取到手機的屏幕相關信息之后動態設置position中left和top 的值

人狠話不多,直接上代碼!

//獲取用戶手機相關信息getUserSystemInfo:function(){var that = thiswx.getSystemInfo({success: function (res) {console.log("手機型號"+res.model)console.log(res.pixelRatio)console.log(res.windowWidth)console.log(res.windowHeight)console.log(res.language)console.log(res.version)//更新數據console.log(that.data.controls)that.data.controls[0].position.top = (res.windowHeight) * 0.85that.data.controls[1].position.top = (res.windowHeight)*0.85that.data.controls[0].position.left = (res.windowWidth) * 0.27that.data.controls[1].position.left = (res.windowWidth) * 0.54that.setData({UserSystemInfo:res,controls: that.data.controls})}})}
大功告成!愿每一個工程師在開發的道路上少一些坎坷。。。愿世界和平!hiahia~~~

總結

以上是生活随笔為你收集整理的微信小程序 setData动态设置数组中的数据的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。