error message wx is not defined是什么原因?
发布于 5 年前 作者 rxiang 1865 次浏览 来自 问答

云函数定义如下

const cloud=require('wx-server-sdk');
cloud.init()
 
const db=wx.cloud.database();
 
// 云函数入口函数
exports.main = async (event, context) => {
  try{
    await db.collection('users').where({
      username: "zhangsan"
    }).remove()
  }catch(e){
    console.log(e)
  }
   
}
1 回复

本地代码也要初始化。

回到顶部