IT门户, 中国互联网人工智能物联网行业资讯平台--公众IT
新闻来源:互联网资料整理       发布时间:2023/4/5 16:31:54       共计:4611 浏览

前言:

2小时前小编发现微信小程序用户:【谨丰】提出了一个关于“小程序多次添加数据到一个云数据库上,后台云数据库只接收第一次的数据,这是个bug么?”的问题,在问题中开发者谨丰对该问题做了如下阐述:

问题类型:


  • API和组件:

问题描述:

wxml

 <text>商品名称</text>

  <input bindinput=”Getname“> </input>

  <text>商品价格</text>

  <input bindinput=”Getprice“> </input>

  <text>商品数量</text>

  <input bindinput=”Getnumber“> </input>

  <text>商品详情及联系方式</text>

  <input bindinput=”Getdetail” style=”width: 750rpx; height: 244rpx; display: block; box-sizing: border-box“> </input>

<button bindtap=”Getimg” style=”position: relative; left: 0rpx; top: 122rpx“>上传商品图片</button>

<button bindtap=”Getdata” style=”position: relative; left: 0rpx; top: 244rpx“>上传商品</button>

js如下希望大佬救救我

let Name=

let Price=

let Number=

let Detail=

let Img=

let picUrl=

 Page({

   data:{

    list:[],

    img:”,

    fileList:[],

    fileIDs:[]

     },

     onload(){

      this.getlist()

    },

    getlist(){

      wx.cloud.database.collection(goods)

      .get()

      .then(res=>{

        console.log(获取数据成功‘,res)

        this.setData({

          list:res.data

        })

      })

      .catch(err=>{

        console.log(获取数据失败‘,err)

      })

    },

    Getname(e){

   Name=e.detail.value

   console.log(Name)

     },

     Getprice(e){

       Price=e.detail.value

       console.log(Price)

     },

     Getnumber(e){

       Number=e.detail.value

       console.log(Number)

     },

     Getdetail(e){

       Detail=e.detail.value

       console.log(Detail)

     },

     Getdata(){

       console.log(添加的商品名‘,Name)

       console.log(添加的商品价格‘,Price)

       //检测名字是否合法

       if(Name==){

         wx.showToast({

           icon:’none‘,

           title:’商品名称为空

         })

       }

       else if(Price==){

         wx.showToast({

           icon:’none‘,

           title:’商品价格为空

         })

       }

      else if(Number==){

         wx.showToast({

           icon:’none‘,

           title:’商品数量为空

         })

       }

     else if(Detail==){

         wx.showToast({

           icon:’none‘,

           title:’商品详情及联系方式为空

         })

       }

       else{

         wx.cloud.database().collection(goods).add({

           data:{

             name:Name,

             price:Price,

             number:Number,

             detail:Detail

          // img:tempFilePath

             

           }})

       

          .then(res=>{

             console.log(添加数据成功“,res)

             

            

           })

           .catch(err=>{

            console.log(添加数据失败“,err)

           })

         

         

       }

     },

     Getimg(){

       wx.chooseImage({

         success:res=>{

           var filePath=res.tempFilePaths[0]

           this.cloudFile(filePath)

         }

       })

     },

     cloudFile(path){

       wx.cloud.uploadFile({

         cloudPath:Date.now()+.jpg“,

         filePath:path

       })

       .then(res=>{

         this.setData({

           picUrl:res.fileID,

           img:res.fileID

           }

           let fileID=res.fileID;

           wx.cloud.database().collection(goods).add

           ({

             data:{

              img:fileID

             },

             success:res=>{

               console.log(图片上传成功‘,res)

             },

             fail:err=>{

               console.log(图片上传失败‘,err)

             }

             

           })

       })

     },

  

    })

注:以上是微信小程序开发者:”谨丰”对于本问题的一些阐述,这里做一个引用,我们将实时关注微信小程序助手对该问题提出的解决方案。

解决方案:

【2小时前】微信小程序技术运营专员对用户谨丰提出的小程序多次添加数据到一个云数据库上,后台云数据库只接收第一次的数据,这是个bug么?给予如下回复

至少没验证价格和数量是不是数字,而且传上去的也是文本,没处理成数字。

结语:

微信官方小程序的优势是,其用户体验可以最大限度的接近Native App。因此,微信官方智能小程序也把用户体验作为一个核心进行了优化

如果您也在使用微信小程序,请关注我们,如果您有关于微信小程序的使用问题请关注我们,如果您要找百度小程序模板、微信小程序模板请关注小程序模板网或者去微信开放社区找官方人员给予解决,相信微信官方在小程序上的发力会是一个里程碑!

版权说明:
本网站凡注明“公众IT 原创”的皆为本站原创文章,如需转载请注明出处!
本网转载皆注明出处,遵循行业规范,如发现作品内容版权或其它问题的,请与我们联系处理!
您可以扫描右侧微信二维码联系我们。
网站首页 关于我们 联系我们 合作联系 会员说明 新闻投稿 隐私协议 网站地图