Guoguo-notes
主页
  • 常用笔记
  • 飞码篇
  • Java
  • React笔记
  • 袁果锅生态
GitHub
主页
  • 常用笔记
  • 飞码篇
  • Java
  • React笔记
  • 袁果锅生态
GitHub
  • 常用笔记

    • CSS 封装.md
    • CSS笔记.md
    • Echarts.md
    • Element Plus --vue3.0.md
    • Element ui 笔记.md
    • Git 代码管理.md
    • Html 笔记.md
    • Taro.md
    • TypeScript.md
    • Vue 代码片段.md
    • Vue 全局封装 main.js.md
    • Vue 笔记.md
    • Vue3 .md
    • Vue3+Element Plus.md
    • axios 请求拦截.md
    • ecahrts 使用地图报错问题.md
    • element plus 本地启动.md
    • jsx tsx 代码片段.md
    • jsx tsx 笔记.md
    • js常规.md
    • npm.md
    • sh 笔记.md
    • uniapp笔记.md
    • valibot校验学习.md
    • vite 笔记.md
    • vite手写插件.md
    • vue.js 下载文件.md
    • vueuse笔记.md
    • vxe-table笔记.md
    • 云开发教程.md
    • 公共API接口.md
    • 小程序笔记.md
    • 常用插件.md
    • 插件库.md
    • 服务器.md
    • 服务器部署教学.md
    • 毕业设计接单.md
    • 汇智腾远笔记.md
    • 浏览器px to rem适配.md
    • 登录流程.md
    • 登录逻辑.md
    • 网站配色.md
    • 视频播放插件.md
    • 解析数学公式.md
    • 跨域代理.md

1.买一个环境,可以得到一个环境ID

2.在app.vue 里面写

onShow: function() {
    wx.cloud.init({
        env: "guoguo-school-9gyphpbe161a19f9"
    })
    console.log('App Show')
},

3. 在页面中调用

guoguoBox 是 自己的数据库表名

const db = wx.cloud.database();
db.collection('guoguoBox').where({
    sex: this.sextext
}).get({
    success: (res => {
        this.dataLength = res.data.length
        this.getbox2 = res.data
    })
})

完整代码

<template>
  <view class="container">
    <button @click="init(0)">status=0</button>
    <button @click="init(1)">status=1</button>
    <button @click="init(2)">status=2</button>
  </view>
</template>

<script>
  export default {
    methods: {
      init(e) {
        const db = wx.cloud.database();
        db.collection('life-numbers').where({
          status:e
        }).get({
          success: (res => {
            console.log(res);
          })
        })
      }
    }
  }
</script>

为什么不在main里面注册

小程序路径转电脑端=> 临时路径

https://docs.cloudbase.net/storage/get-temp-url
Edit this page
Last Updated:
Contributors: 袁果锅
Prev
vxe-table笔记.md
Next
公共API接口.md