TypeError: auth.anonymousAuthProvider is not a function
vue中使用微信云开发的库
代码如下:
import cloudbase from "@cloudbase/js-sdk"
export default {
name: 'xxx',
data () {
return {
msg: 'xxxx'
}
},
beforeCreate: function () {
//页面初始化
this.$nextTick(() => {
this.InitData();
});
},
methods: {
//页面初始化
InitData() {
console.log("hello world")
this.msg="hello world"
const app = cloudbase.init({env: "cloud1-xxxxxxxxxx"});
const auth = app.auth({ persistence: "local" });
const provider=auth.anonymousAuthProvider();
provider.signIn()
.then(() => {
console.log("匿名登录成功");
})
.catch(err => {
console.log(err);
});
app
.callFunction({
name: "getOpenId"
})
.then((res) => {
const result = res.result; //云函数执行结果
});
}
},
beforeDestroy() {
}
}
错误截图:
已仔细检查过,anonymousAuthProvider 这个函数名称拼写没错。
试了库的其他函数没这问题。
请帮忙看看