【问题标题】:How can i use script src?如何使用脚本 src?
【发布时间】:2021-03-16 12:26:45
【问题描述】:

我正在尝试在 html 文件的 js 代码中使用 errLogin 模块。

这是 main.js 文件。

import puppeteer from "puppeteer"
const errLogin = false;
...

export default { errLogin }

这是 test.html 文件。

<!doctype html>
<html lang="ko">

<head>
    <meta charset="utf-8">
    <title>main</title>
    <style>
        body {
            font-family: Consolas, monospace;
        }
    </style>
     <script src="./account.js"></script>
     <script type="module">
        import { errLogin } from "./main.js"
        console.log(errLogin)
     </script>
</head>

<body>
    <div>
        <p id="email"></p>
        <p id="password"></p>
    </div>
    <script>
            const CirculateData = () =>{
                for (let key in account)
                {
                    if (!errLogin) return account[key];
                    else return account[Number(key) + 1];
                }
            };
            
            document.querySelector("#email").innerHTML = CirculateData().email
            document.querySelector("#password").innerHTML = CirculateData().password
             
    </script>

</body>

</html>

错误信息。

Uncaught TypeError: Failed to resolve module specifier "puppeteer". Relative references must start with either "/", "./", or "../".

这是文件夹结构。

我该怎么做?我该怎么做?我该怎么做?我该怎么做?我该怎么做?我该怎么做?我该怎么做?我该怎么做?我该怎么做?我该怎么做?

【问题讨论】:

  • 什么是文件夹结构?你能告诉我文件夹结构吗
  • 添加了!请确认。

标签: javascript html puppeteer script


【解决方案1】:

类型模块使用 src 参数,然后浏览器不知道导入|导出,你需要 Webpack 或其他捆绑器

【讨论】:

  • 我应该如何搜索?
猜你喜欢
  • 2023-04-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-01-28
  • 2019-05-28
  • 2014-02-17
相关资源
最近更新 更多