我有一个使用Vite构建的React应用程序,其中我正在实现一个外部JS脚本。
我在
该脚本位于
有人能指出如何使这个工作吗?
我在
index.html
上加载该脚本,在开发过程中它可以正常工作,但是当我将其打包到生产环境时,脚本无法加载。
起初,我收到了一个错误,需要在加载脚本时包含type="module"
,并且这个错误得到了修复。但是当我访问使用该脚本的应用程序部分时,我会遇到未定义的错误。该脚本位于
/vendors/faceio/fio.js
。<body>
<!-- <script src="https://cdn.faceio.net/fio.js"></script> -->
<script type="module" src="/vendors/faceio/fio.js"></script>
<div id="root"></div>
<script type="module" src="/src/index.jsx"></script>
<script>
const global = globalThis;
</script>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
有人能指出如何使这个工作吗?