怎么制作微信小程序的遍历数组的单选功能

怎么制作微信小程序的遍历数组的单选功能,第1张

1、升级你的到最新的653版本。 2、在的第铅顷宏一个页面顶端,有一个搜索条,在搜索条里输入:小程序示例然后搜索。点最下面的:搜一搜 小程序示例 朋友圈、公众号、文章乎迹等。槐册 3、选择第一个结果,图标是黑色斜写的英文字母“S”,点开它 4、看如何制作微信小程序的遍历数组的单选

首先在wxml中是无法显示app.js中的全局变量(也就是app.js里面globalData中的变量),如果想用到app.js中的变量时可以在当前页面中的js文件里面先将全局变量获取的本地。

<html>

<head>

<title>无标题</title>

</head>

<body>

<script type="text/javascript">

var ac = ['id1','id2']

var ad = ['title1','title2']

var ae = ['uid1','uid2']

var af = ['utitle1'消薯,'utitle2']

var r=[]

for(var i=0i<ac.lengthi++)

r.push({id:ac[i],title:ad[i],ulist:[{uid:ae[i],utitle:af[i]}]})

//输出,以进行核对

document.write("[")

for(var i=0i<r.lengthi++)

{

document.write("{")

document.write("id:'"+r[i]['id']+"',")

document.write("title:'"+r[i]['title']+"',")

document.write("ulist:[{uid:'"+r[i]['ulist'][0]['uid']+"销桥猜',")

document.write("utitle:'"+r[i]['ulist'][0]['utitle']+"'}]")

document.write("}")

if(i!=r.length-1)

document.write(",<br />")

}

document.write("]")

<亏型/script>

</body>

</html>


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

原文地址:https://54852.com/yw/12314599.html

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

发表评论

登录后才能评论

评论列表(0条)

    保存