我试图从我网页中的其他脚本访问 Main。
index.html
<html lang="en">
<head>
<script type="module">
export function Main() {
console.log("Hi!");
}
</script>
</head>
<body>
<script type="module">
import { Main } from "main";
Main();
</script>
</body>
</html>
这告诉我
Uncaught TypeError: Failed to resolve module specifier "main". Relative references must start with either "/", "./", or "../".
您可能想知道什么是“主要”?它最初是 Typescript 文件 main.ts,它在编译期间被插入到网页的头部。 还有test.ts,它编译并插入到网页的正文中。
有没有办法解决这个问题?
附言指定的问题是每次请求页面时都会动态更改 src,所以是的。