框架类型 | 问题类型 | 终端类型 | AppID | 环境ID | 基础库版本 |
---|---|---|---|---|---|
小程序 | Bug | 工具 | wxb7c97790a3a45a53 | test-tvfr3 | 2.8.2 |
// 初始化 cloud
cloud.init({
// API 调用都保持和云函数当前所在环境一致
env: cloud.DYNAMIC_CURRENT_ENV
})
可是官方例子的cloud.DYNAMIC_CURRENT_ENV却是Symbol,建议以下改法:
// node_modules/wx-server-sdk/index.d.ts 文件的15行
export interface ICloudConfig {
env?: string | {
database?: string
functions?: string
storage?: string
} | Symbol
traceUser?: boolean
database: {
realtime: {
// max reconnect retries
maxReconnect: number
// interval between reconnection attempt, does not apply to the case of network offline, unit: ms
reconnectInterval: number
// maximum tolerance on the duration of websocket connection lost, unit: s
totalConnectionTimeout: number
}
}
}
题外话,建议考虑开源`wx-server-sdk`,因为反正代码都完全看得到,不如开源让大家补充不足。