- 图片文件能上传存储,数据库字段项中不能中 不能写入图片文件地址记录
var FilePaths = [] let promiseArr = []; for (let i = 0;i< this.data.imgList.length ; i++) { let promise = new Promise((resolve, reject) => { var randstring = Math.floor(Math.random() * 100).toString() + '.png' randstring = randstring wx.cloud.uploadFile({ cloudPath: 'newsImages/' + randstring, filePath: this.data.imgList[i], // 文件路径 success: res => { // get resource ID console.log(res.fileID) FilePaths[i] = res.fileID resolve(res); }, fail: err => { reject(error); } }) }) promiseArr.push(promise) } this.setData({ imgList1: FilePaths }) console.log(this.data.imgList1) // Promise.all(promiseArr).then((result) => { // this.data.imgList1是云空间的文件路径吗? // if (this.data.imgList1.length!= 0) { // this.setData({ // imgList1: this.data.imgList1.concat(FilePaths) // }) //} else { // this.setData({ // imgList1: FilePaths //}) // console.log(this.data.imgList1[0]) //} // wx.hideLoading() // }) /*云数据库记录*/ const db = wx.cloud.database({ env: 'env-1gz2buk367a05f5c' }) //const diliId = db.collection('enginerInformation') var util=require('../../utils/util.js') var date=util.formatTime(new Date()); var data1={ pictureFileId1:FilePaths, tuban:this.data.tuban, beiZhu:e.detail.value.beiZhu, date:date} db.collection('enginerInformation').add({ data:data1, success: function(res) { // res 是一个对象,其中有 _id 字段标记刚创建的记录的 id console.log(res) } }),
2022-08-22 - 云存储中的上传图片File.ID返回值不能全部技术记录入数据库
云存储中的上传图片File.ID返回值不能全部及时记录入数据库 wx.cloud.init( {env:'env-1g'}) var FilePaths = [] let promiseArr = []; for (let i = 0;i< this.data.imgList.length ; i++) { let promise = new Promise((resolve, reject) => { var randstring = Math.floor(Math.random() * 100).toString() + '.png' randstring = randstring wx.cloud.uploadFile({ cloudPath: 'newsImages/' + randstring, filePath: this.data.imgList[i], // 文件路径 success: res => { // get resource ID console.log(res.fileID) FilePaths[i] = res.fileID resolve(res); }, fail: err => { reject(error); } }) }) promiseArr.push(promise) } if (this.data.imgList1.length != 0) { this.setData({ imgList1: this.data.imgList1.concat(FilePaths) }) } else { this.setData({ imgList1: FilePaths }) console.log(this.data.imgList1[1]) } wx.hideLoading() /*云数据库记录*/ const db = wx.cloud.database({ env: 'env-' }) //const diliId = db.collection('enginerInformation') var data1={_id:"1egwgrr 66", otherAccountId: "9xgbb2", pictureFileId1:this.data.imgList1, userId:"2sdskjhjjj就"} db.collection('enginerInformation').add({ data:{ data1 } , success: function(res) { // res 是一个对象,其中有 _id 字段标记刚创建的记录的 id console.log(res) } }) 上传图片file.id不能及时写入数据库
2022-03-14 - navigator组件从本小程序的页面不能调到本小程序的插件页面?
[图片] <navigator id="nav" url="plugin://hello-plugin/pages/index/index"> Go to Plugin page </navigator> <view bindtap="tiaozhuan" >跳转</view>
2021-03-22 - 本小程序中使用navigator组件不能导航到插件内页面?
<navigator id="nav" url="plugin://hello-plugin/pages/index/index"> Go to Plugin page </navigator> 以下是插件配置页面 { "pages":{ "index": "pages/index/index", "person": "pages/person/person" }, app配置 { "pages": [ "pages/index/index" ], "plugins": { "hello-plugin": { "version": "dev", "provider": "我的ID" } }, "sitemapLocation": "sitemap.json" }
2021-03-19