当前位置:网站首页>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
边栏推荐
- Problem C: Hanoi Tower III
- What to pay attention to when writing the first code
- Three types of cyclic structure
- Generate QR code through zxing
- The art of concurrent programming (2): synchronized usage scenarios
- QT uses drag and drop picture to control and mouse to move picture
- Mechanical design knowledge point planning
- 2022 团体程序设计天梯赛 模拟赛 L2-4 哲哲打游戏 (25 分)
- 移植tslib时ts_setup: No such file or directory、ts_open: No such file or director
- Database - MySQL -- Navicat import SQL error 1067 - invalid default value for 'paydate‘
猜你喜欢

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

File upload vulnerability summary and upload labs shooting range documentary

Codeforces Round #784 (Div. 4)题解 (第一次AK cf (XD

Software testing process

C interface
![Detailed description of MySQL index [B + tree index, hash index, full-text index, overlay index]](/img/1a/a22b4a35d3c083438d0f766a5ecb08.png)
Detailed description of MySQL index [B + tree index, hash index, full-text index, overlay index]

Supersocket is Used in net5 - command

C abstract class

On the principle of concurrent programming and the art of notify / Park

对象和类的概念
随机推荐
Activity supports multi window display
Explanation keyword of MySQL
The art of concurrent programming (3): an in-depth understanding of the principle of synchronized
Variable definition and use
Create virtual machine
Unity basics 2
Leetcode punch in diary day 01
PyMOL usage
POI create and export Excel based on data
Initial experience of talent plan learning camp: communication + adhering to the only way to learn open source collaborative courses
变量、常量、运算符
SQL learning record
C-11 problem h: treasure chest 2
What to pay attention to when writing the first code
Unity games and related interview questions
2022 group programming ladder simulation match 1-8 are prime numbers (20 points)
The art of concurrent programming (5): the use of reentrantlock
List interface of collection
There is no index in the database table. When inserting data, SQL statements are used to prevent repeated addition (Reprint)
Test questions and some space wars