简体   繁体   English

如何使用脚本 src?

[英]How can i use script src?

I am trying to use errLogin module in js code in html file.我正在尝试在 html 文件的 js 代码中使用 errLogin 模块。

THis is main.js file.这是 main.js 文件。

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

export default { errLogin }

THis is test.html file.这是 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>

error message.错误信息。

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

this is folder structure.这是文件夹结构。

在此处输入图像描述

How can I do it?我该怎么做? How can I do it?我该怎么做? How can I do it?How can I do it?我该怎么做?我该怎么做? How can I do it?我该怎么做? How can I do it?我该怎么做? How can I do it?我该怎么做? How can I do it?我该怎么做? How can I do it?我该怎么做? How can I do it?我该怎么做?

Type module work with src argument, then browsers don't know about import|export, you need Webpack or another bundler类型模块使用 src 参数,然后浏览器不知道导入|导出,你需要 Webpack 或其他捆绑器

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM