当前位置:网站首页>Wechat applet cloud database value assignment to array error
Wechat applet cloud database value assignment to array error
2022-04-23 03:35:00 【CSDN Q & A】
The code is as follows :
Page({
data: {
url:[], // Array
},
previewImage:function(event){
wx.cloud.database().collection("imgs").where({op:'1'}).get({
success:function(res){
for(var i=0;i<res.data.length;i++){
var newar = {
site:JSON.stringify(res.data[i].url)
};
this.data.url = this.data.url.concat(newar);// Array assignment
this.setData({
url:this.data.url
});
}
}
}),
wx.previewImage({
//urls: ["cloud://huqq12-5gd07ykk20bc150b.6875-huqq12-5gd07ykk20bc150b-1311173720/2.png"] // Contents of the desired array
urls: [url]
})
},
})
Report errors :

database

Take the answer :
Write it like this... Try it
previewImage:function(event){ var _this = this; wx.cloud.database().collection("imgs").where({op:'1'}).get({ success:function(res){ for(var i=0;i<res.data.length;i++){ var newar = { site:JSON.stringify(res.data[i].url) }; let tempData = _this.data.url.concat(newar);// Array assignment _this.setData({ url:tempData }); } } }), wx.previewImage({ //urls: ["cloud://huqq12-5gd07ykk20bc150b.6875-huqq12-5gd07ykk20bc150b-1311173720/2.png"] // Contents of the desired array urls: [url] }) }
版权声明
本文为[CSDN Q & A]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204151501087501.html
边栏推荐
- On the principle of concurrent programming and the art of notify / Park
- Database SQL -- simulate inserting a large amount of data, importing / exporting database scripts, timestamp conversion and database basics
- 常用的辅助类
- List interface of collection
- Query stored procedures in PostgreSQL
- Do you really understand hashcode and equals???
- AWS from entry to actual combat: creating accounts
- [microservices] (x) -- Unified gateway
- L3-011 直捣黄龙 (30 分)
- Un aperçu des flux d'E / s et des opérations de fichiers de classe de fichiers
猜你喜欢

Optimization of especially slow startup in idea debugging mode

Seekbar custom style details

MySQL keyword group_ Concat, combined connection query

2022 团体程序设计天梯赛 模拟赛 L2-3 浪漫侧影 (25 分)

MySQL query specifies that a row is sorted to the first row

Punch in: 4.22 C language chapter - (1) first knowledge of C language - (11) pointer

L3-011 direct attack Huanglong (30 points)

2022 group programming ladder simulation l2-1 blind box packaging line (25 points)

. net webapi access authorization mechanism and process design (header token + redis)

MySQL zip installation tutorial
随机推荐
Unity Basics
Deep learning notes (II) -- principle and implementation of activation function
Super easy to use asynchronous export function of Excel
PyMOL usage
C-10 program error correction (recursive function): number to character
2022 团体程序设计天梯赛 模拟赛 1-8 均是素数 (20 分)
Initial experience of talent plan learning camp: communication + adhering to the only way to learn open source collaborative courses
2022 group programming ladder simulation match 1-8 are prime numbers (20 points)
String input problem
Three types of jump statements
QT uses drag and drop picture to control and mouse to move picture
L3-011 direct attack Huanglong (30 points)
C abstract class
移植tslib时ts_setup: No such file or directory、ts_open: No such file or director
2022 团体程序设计天梯赛 模拟赛 L1-7 矩阵列平移 (20 分)
打卡:4.23 C语言篇 -(1)初识C语言 - (12)结构体
Design and implementation of redis (3): persistence strategy RDB, AOF
淺學一下I/O流和File類文件操作
When migrating tslib_ setup: No such file or directory、ts_ open: No such file or director
Download and configuration of idea