Javascript 当使用and import语句和HTML时,我没有得到任何输出。为什么?

Javascript 当使用and import语句和HTML时,我没有得到任何输出。为什么?,javascript,html,es6-modules,Javascript,Html,Es6 Modules,使用导入时,我得到一个空白页。我有一个简单的程序,只是为了测试import语句。我不知道为什么我没有得到任何输出。以下是我在应用程序js中的代码: import TestComponent from "./components/Testcomponentfile" pageBuild(); function pageBuild(){ TestComponent(); } 以下是组件的代码: export default function TestComponent(){ c

使用导入时,我得到一个空白页。我有一个简单的程序,只是为了测试import语句。我不知道为什么我没有得到任何输出。以下是我在应用程序js中的代码:

import TestComponent from "./components/Testcomponentfile"

pageBuild();

function pageBuild(){
    TestComponent();
}
以下是组件的代码:

export default function TestComponent(){
    console.log("test component js");
    return `    
    <h1>HTML test</h1>
     `

}
export default function TestComponent(){
    console.log("test component js");
    return `    
    <h1>HTML test</h1>
     `

}
导出默认函数TestComponent(){
log(“测试组件js”);
返回`
HTML测试
`
}
下面是index.HTML:

<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <script type="text/javascript"></script>
  <title>Document</title>
</head>
<body>
  <div id="demo"></div>
<div>
  <h1> test Html</h1>
</div>

<script src="./JS/app.js"></script>

</body>
</html>

文件
测试Html
我缺少什么??

调用
pageBuild()定义函数后未解决问题>
我正在使用谷歌浏览器。它应该是有效的

import TestComponent from "./components/Testcomponentfile"

function pageBuild(){
    TestComponent();
}

pageBuild();
以下是组件的代码:

export default function TestComponent(){
    console.log("test component js");
    return `    
    <h1>HTML test</h1>
     `

}
export default function TestComponent(){
    console.log("test component js");
    return `    
    <h1>HTML test</h1>
     `

}
ap.js

export default function TestComponent(){
    console.log("test component js");
    return `
    <h1>HTML test</h1>
     `

}
import TestComponent from "./tc.js"

function pageBuild(){
    console.log(TestComponent());
}

pageBuild();
经过测试,效果良好

使用脚本时在html中使用
type=“module”


文件
测试Html

在大多数情况下,web浏览器不支持ES模块或
import
语句,它主要用于Node.js中的服务器端JavaScript。这就是为什么人们通过
require
使用Bundler或SystemJS进行运行时导入的原因。我将pagebuild()函数放在函数定义下面,但仍然得到一个空白页。让我重新使用es模块,这次我使用的是es6。对我来说还是不行。一定是出了什么事。我可以直接与您联系吗?这个函数pageBuild(){console.log(TestComponent());只是将html发送到控制台。我希望它出现在页面上。您使用什么来呈现html