- 添加的一个开发者,不能打开云开发控制台?
各路大神,我实在搞不明白了。 我用的云开发,登陆微信公众平台授权添加一位开发者,为什么他登陆微信开发工具后不能使用云开发?云开发的按钮是灰色的。但是我试了下授权给我另一个微信号就可以,这是为什么呢? 谢谢!
2019-11-25 - 循环内的wx.cloud.uploadFile返回值无法和index同步怎么办?
搞了好几天了解决不了,有没有大神为我解答? 云开发上传多个图片,用户选择多个图片,上传时显示进度,上传完成后图片按照当时的选择顺序显示。 代码大致结构如下: [代码]data: {[代码][代码] [代码][代码]imagesPreview: [][代码][代码]},[代码][代码]postImages: [代码][代码]function[代码][代码]() {[代码][代码] [代码][代码]wx.chooseImage({[代码][代码] [代码][代码]//选择9张图片[代码][代码] [代码][代码]success: [代码][代码]function[代码][代码](res) {[代码][代码] [代码][代码]var[代码] [代码]filePaths = res.filePaths[代码][代码] [代码] [代码] [代码][代码]//把本地临时路径放在集合里[代码][代码] [代码][代码]for[代码] [代码]([代码][代码]var[代码] [代码]i [代码][代码]in[代码] [代码]filePaths) {[代码][代码] [代码][代码]var[代码] [代码]imagesTemp = { [代码][代码]'filePath'[代码][代码]: filePaths[i], [代码][代码]'fileID'[代码][代码]: [代码][代码]''[代码][代码], [代码][代码]'progress'[代码][代码]: 0 }[代码][代码] [代码][代码]that.data.imagesPreview.push(imagesTemp)[代码][代码] [代码][代码]}[代码] [代码] [代码][代码]//再一次循环,根据上传返回结果依次改变集合内的对应值[代码][代码] [代码][代码]for[代码] [代码]([代码][代码]var[代码] [代码]j [代码][代码]in[代码] [代码]filePaths) {[代码][代码] [代码][代码]var[代码] [代码]filePath = that.data.imagesPreview[j].filePath[代码][代码] [代码][代码]var[代码] [代码]fileName = common.getUniqueFileName(app.globalData.userInfo._id)[代码][代码] [代码][代码]var[代码] [代码]cloudPath = fileName + filePath.match(/\.[^.]+?$/)[0][代码][代码] [代码][代码]var[代码] [代码]uploadTask = wx.cloud.uploadFile({[代码][代码] //[代码][代码]...[代码][代码] [代码][代码]success: res => {[代码][代码] [代码][代码]that.data.imagesPreview[j].fileID = res.fileID[代码][代码] [代码][代码]that.setData({[代码][代码] [代码][代码]imagesPreview: that.data.imagesPreview[代码][代码] [代码][代码]})[代码][代码] [代码][代码]}[代码][代码] [代码][代码]})[代码] [代码] [代码][代码]uploadTask.onProgressUpdate((res) => {[代码][代码] [代码][代码]that.data.imagesPreview[j].progress = res.progress[代码][代码] [代码][代码]that.setData({[代码][代码] [代码][代码]imagesPreview: that.data.imagesPreview[代码][代码] [代码][代码]})[代码][代码] [代码][代码]})[代码][代码] [代码][代码]}[代码][代码] [代码][代码]},[代码][代码] [代码][代码]})[代码][代码]},[代码] 比如选了3张图片 [代码]imagePreview = [[代码] [代码]{[代码][代码]'filePath'[代码][代码]:[代码][代码]'地址1'[代码][代码],[代码][代码]'fileID'[代码][代码]:[代码][代码]''[代码][代码],[代码][代码]'progress'[代码][代码]:0},[代码] [代码]{[代码][代码]'filePath'[代码][代码]:[代码][代码]'地址2'[代码][代码],[代码][代码]'fileID'[代码][代码]:[代码][代码]''[代码][代码],[代码][代码]'progress'[代码][代码]:0},[代码] [代码]{[代码][代码]'filePath'[代码][代码]:[代码][代码]'地址3'[代码][代码],[代码][代码]'fileID'[代码][代码]:[代码][代码]''[代码][代码],[代码][代码]'progress'[代码][代码]:0}[代码] [代码]][代码] 当准备上传这3张图片时,进度progress只会在最后一个{'filePath':'地址3','fileID':'','progress':0}里面更新,返回的fileID也是。 查了遍console.log,应该是由于上传文件是异步处理,遍历完了之后uploadFile结果还没返回,并且j停留在集合最后一个。 所以问题来了,要做到fileID和progress都能在集合内对应的位置更新该怎么办?
2019-11-05 - 上传图片有时会失败什么原因?
我是云开发,试过单图上传和多图上传,有onProgressUpdate进度监控,到达100%时有时会上传失败,错误代码为:Error: errCode: -1 | errMsg: empty fileid; upload sign invalid; 查看控制台存储,图片确实没有传上去。但没传上去的话为什么进度能显示100%呢?是不是云开发对图片大小有限制?
2019-11-04 - uploadTask进度前台显示报错?
大神们帮我看看 这是咋回事呢[代码]postImages: [代码][代码]function[代码] [代码]() {[代码][代码] [代码] [代码] [代码][代码]var[代码] [代码]that = [代码][代码]this[代码][代码] [代码][代码]var[代码] [代码]quantity = 9[代码][代码] [代码] [代码] [代码][代码]query.chooseImages(quantity, [代码][代码]function[代码][代码](imageRes){[代码][代码] [代码] [代码] [代码][代码]var[代码] [代码]filePaths = imageRes.tempFilePaths [代码][代码] [代码] [代码] [代码][代码]for[代码] [代码]([代码][代码]var[代码] [代码]i = 0; i < filePaths.length; i++) {[代码][代码] [代码] [代码] [代码][代码]var[代码] [代码]filePath = filePaths[i][代码][代码] [代码] [代码] [代码][代码]var[代码] [代码]imagesPreviewTemp = {[代码][代码]'filePath'[代码][代码]:filePath,[代码][代码]'fileID'[代码][代码]:[代码][代码]''[代码][代码],[代码][代码]'progress'[代码][代码]:0}[代码] [代码] [代码][代码]that.data.imagesPreview.push(imagesPreviewTemp)[代码] [代码] [代码][代码]that.setData({[代码] [代码] [代码][代码]imagesPreview:that.data.imagesPreview[代码] [代码] [代码][代码]})[代码][代码] [代码] [代码] [代码][代码]var[代码] [代码]fileName = common.getUniqueFileName(app.globalData.userInfo._id)[代码] [代码] [代码][代码]var[代码] [代码]cloudPath = fileName + filePath.match(/\.[^.]+?$/)[0][代码][代码] [代码] [代码] [代码][代码]query.uploadImages(cloudPath, filePath, [代码][代码]function[代码][代码](res) {[代码] [代码] [代码][代码]//uploadFile成功后回调[代码] [代码] [代码][代码]var[代码] [代码]fileID = res.fileID[代码] [代码] [代码][代码]that.data.imagesPreview[i].fileID = fileID[代码][代码] [代码] [代码] [代码][代码]that.setData({[代码] [代码] [代码][代码]imagesPreview: that.data.imagesPreview[代码] [代码] [代码][代码]})[代码][代码] [代码] [代码] [代码][代码]}, [代码][代码]function[代码][代码](res) {[代码] [代码] [代码][代码]//uploadTask.onProgressUpdate成功后回调[代码][代码] [代码] [代码] [代码][代码]that.data.imagesPreview[i].progress = res.progress[代码][代码] [代码][代码]// 一直在这里报错,说that.data.imagesPreview[i].progress is not defined.[代码][代码] [代码] [代码] [代码][代码]that.setData({[代码] [代码] [代码][代码]imagesPreview: that.data.imagesPreview[代码] [代码] [代码][代码]})[代码][代码] [代码][代码]console.log([代码][代码]'上传进度'[代码][代码], res.progress)[代码][代码] [代码][代码]// console.log('已经上传的数据长度', res.totalBytesSent)[代码][代码] [代码][代码]// console.log('预期需要上传的数据总长度', res.totalBytesExpectedToSend)[代码][代码] [代码][代码]})[代码][代码] [代码][代码]}[代码][代码] [代码][代码]// wx.hideLoading()[代码][代码] [代码] [代码] [代码][代码]})[代码][代码] [代码][代码]},[代码] 一直报错说that.data.imagesPreview[i].progress is not defined. 但是初始值已经有了个progress:0了,为什么会报错呢?
2019-11-03 - filePath.match()[0]后面的[0]是什么意思?
Quickstart里上传图片的函数有一段不太明白。 [代码]const filePath = res.tempFilePaths[0][代码][代码] [代码] [代码] [代码][代码]// 上传图片[代码][代码]const cloudPath = [代码][代码]'my-image'[代码] [代码]+ filePath.match(/\.[^.]+?$/)[0][代码][代码] [代码] [代码] wx.cloud.uploadFile({[代码] [代码] [代码] [代码] cloudPath,[代码] [代码] [代码][代码]filePath,[代码][代码] [代码] [代码] success: res => {...[代码]} filePath.match(/\.[^.]+?$/)[0] 这里的[0]是什么意思呢?
2019-11-02 - db.collection().where()查询语句不能用变量?
各位有没有遇到过查询语句不能用变量代替的情况? 我想把数据库相关的代码封装起来,方便之后调用。 数据库有一条记录,但调用后查询结果却是0(无记录)。不知道为什么,如果不使用外部js,而是直接写在页面里就没问题。全程无报错,这是咋回事呢? [代码]function[代码] [代码]loadQuery(collection, key, value, callback) {[代码] [代码] [代码][代码]const db = wx.cloud.database()[代码] [代码] [代码][代码]db.collection(collection).where({[代码][代码] [代码][代码]key: value[代码][代码] [代码][代码]}).get({[代码][代码] [代码][代码]success: res => {[代码][代码] [代码][代码]if[代码] [代码](res.data.length == 1){[代码][代码] [代码][代码]typeof[代码] [代码]callback == [代码][代码]"function"[代码] [代码]&& callback(res.data[0])[代码][代码] [代码][代码]console.log([代码][代码]'js/db.js 数据库查询成功, length: '[代码][代码], res.data.length)[代码][代码] [代码][代码]}[代码][代码]else[代码] [代码]if[代码][代码](res.data.length == 0) {[代码][代码] [代码][代码]typeof[代码] [代码]callback == [代码][代码]"function"[代码] [代码]&& callback(res.data[0])[代码][代码] [代码][代码]console.log([代码][代码]'js/db.js 无数据, length: '[代码][代码], res.data.length)[代码][代码] [代码][代码]}[代码][代码]else[代码][代码]{[代码][代码] [代码][代码]console.log([代码][代码]'js/db.js 数据库异常, length: '[代码][代码], res.data.length)[代码][代码] [代码][代码]}[代码][代码] [代码][代码]},[代码][代码] [代码][代码]fail: res => {[代码][代码] [代码][代码]//...[代码][代码] [代码][代码]},[代码][代码] [代码][代码]complete: res => {[代码][代码] [代码][代码]//...[代码][代码] [代码][代码]}[代码][代码] [代码][代码]})[代码][代码]}[代码][代码]module.exports.loadQuery = loadQuery;[代码]
2019-10-30 - 云开发在海外有CDN加速吗?
请教各位大神,我们想以海外公司来注册小程序,主要在海外运营。有几个疑惑想确认一下: 使用云开发的话,是不是不用再买域名和主机了?那备案还需要吗? 云开发是不是和腾讯云阿里云一样有海外CDN加速?找了很久,找不到相关信息。 海外版小程序在功能上有删减吗?有没有官方的对照表可以参考下? 希望各位大神或者官方能说明一下,万分感谢啊!
2019-10-18