【报Bug】支付宝云在HbuildX 进行本地调试时不支持 redis ,我是使用的 Hbuildx 4.24 ,在进行本地的 hello unicloud 中的 redis-test 中报
22:52:10.834 [本地运行]Error: [DCloud-clientDB]: 函数不允许调用
22:52:10.834 [本地运行] at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
22:52:10.834 [本地运行] at async D:\workspace\HBuilderX\plugins\unicloud\alipay\index.js:1:25031
我的测试的代码是
// 简单的使用示例
'use strict';
const redis = uniCloud.redis()
exports.main = async (event, context) => {
const {
action,
data
} = event
const {
key, value
} = data
let res;
switch (action) {
case 'set':
res = redis.set(key, value)
break;
case 'get':
res = redis.get(key)
break;
case 'mget':
let keys = data.keys.split(',')
res = redis.mget(...keys)
break;
case 'mset':
let msetData = data.msetData.split(',')
res = redis.mset(...msetData)
break;
case 'lpush':
res = redis.lpush(key, value)
break;
case 'lindex':
res = redis.lindex(key, data.index)
break;
case 'lrange':
res = redis.lindex(key, ...data.indexs)
break;
case 'llen':
res = redis.llen(key)
break;
case 'del':
res = redis.del(key)
break;
default:
return 'error action in no'
break;
}
return res
};
运行测试的参数是 redis-test.param.json 内容是
{
"action": "set",
"data": {
"key": "dddd",
"value": "fukai"
}
}
2 个回复
s***@163.com - 闷骚IT男
我的也是,网页端可以,微信小程序不允许调用
DCloud_云服务_moyang
用HBuilderX 4.31 alpha试一下