[英]Pop up slider not working in IE. Some javascript interfering css code. Please help me
[英]JavaScript custom module is not working, some help please
我正在制作一個導入彈出框的 JavaScript 模塊,但導入似乎不起作用。 我需要一些幫助才能使我的 javascript 程序正常工作
https://github.com/Daniel4-Scratch/JuiceBox
<!DOCTYPE html>
<html lang="en">
<head>
<script>
import {juiceBox} from 'module/pack.js';
import {juiceBoxPopup} from 'module/pack.js';
juiceBox() // Import it
juiceBoxPopup("Hello!", "Hi my name it bob", "Copyright me") // Launch it
</script>
<link rel="stylesheet" href="module/pack.css">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<button id="jb-btn">Open Box</button>
</body>
</html>
有兩個問題:
您不能在腳本中使用import
,只能在模塊中使用。 要指示您的內聯代碼是一個模塊,您需要將type="module"
添加到script
標記中:
<script type="module"> import {juiceBox} from "module/pack.js"; // ...
瀏覽器中的模塊路徑(除非您使用導入映射)必須以.
或..
或絕對網址。 所以在你的情況下, ./module/pack.js
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.