环境是vue3+ts,需要使用腾讯云开发的能力。
先安装云开发SDK(初始化 | 云开发 CloudBase - 一站式后端云服务)
到这里都没有问题。
main.ts默认是这样的:
[JavaScript] 纯文本查看 复制代码 import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
createApp(App).use(router).mount('#app')
一旦引入SDK,就发生了一个警告。
引入代码是这样的:
[Asm] 纯文本查看 复制代码 import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
// 这里开始引入云开发
import cloudbase from "@cloudbase/js-sdk";
const app = cloudbase.init({
env: "hello96c"
});
// const auth = app.auth({
// persistence: "local"
// });
// async function login() {
// await auth.anonymousAuthProvider().signIn();
// // 匿名登录成功检测登录状态isAnonymous字段为true
// const loginState: any = await auth.getLoginState();
// console.log(loginState.isAnonymousAuth); // true
// }
// login();
createApp(App).use(router).mount('#app')
警告是这样的:
[JavaScript] 纯文本查看 复制代码 Module not found: Error: Can't resolve 'crypto' in 'D:\OneDrive\code\WWW\vue\helloweb\app\node_modules\[email]_bson@4.6.2[/email]@bson\dist'
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback 'resolve.fallback: { "crypto": require.resolve("crypto-browserify") }'
- install 'crypto-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "crypto": false }
试了某度的几个方法都无法解决。
求指教。 |