-
-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nuxt3中提示md5 is not defined #27
Comments
可以提供一下demo代码吗
|
https://codesandbox.io/p/sandbox/zen-taussig-g2kqxb?file=%2Fapp.vue&selection=%5B%7B%22endColumn%22%3A1%2C%22endLineNumber%22%3A7%2C%22startColumn%22%3A1%2C%22startLineNumber%22%3A7%7D%5D |
了解了,我尝试定位一下问题 |
如果先全局引入SDK,则一切正常,而这会导致所有页面都引入SDK
|
同nuxt3中出现该问题 |
经过排查,百度地图SDK中 md5 方法 // Note: kA 经过混淆,为实际md5方法
if (typeof define === "function" && define.amd) {
define(function() {
return kA
})
} else {
if (typeof module === "object" && module.exports) {
module.exports = kA
} else {
kB.md5 = kA
}
} 但在 { hot: false } 此行为导致 如果预先定义 <template>
<BMap @initd="onBMapInitdHandler">
<BZoom />
</BMap>
</template>
<script lang="ts" setup>
import { onBeforeMount } from 'vue'
import { BMap, BZoom } from 'vue3-baidu-map-gl'
let moduleObject;
onBeforeMount(() => {
moduleObject = module;
// eslint-disable-next-line no-global-assign
(module as unknown) = undefined;
})
const onBMapInitdHandler = () => {
// eslint-disable-next-line no-global-assign
(module as unknown) = moduleObject;
}
</script> 应当存在更好的解决方案(或配置),建议等待后续完整的解决方案。 |
临时解决方案是外围多加载一个MD5js,例如:仅供参考
|
nuxt: ^3.3.1
node: v16.13.0
npm: 8.1.0
老哥,我这里有这个问题,看看解决一下呗
The text was updated successfully, but these errors were encountered: