解决办法:

增加:<script type="module">中增加type的类型是module;

demo1.js

export var name = "yzxing";
export let age = "26";

export function person(name, age) {
    this.name = name;
    this.age = age;
    return `${this.name} ++++ ${this.age}`
}

html:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <title>模块</title>
</head>
<body>
<script>
    import {name, age} from "./JS/demo1.js";

    console.log(name, age)
</script>
</body>
</html>

报错:

JS报错:Cannot use import statement outside a module_js

解决:

JS报错:Cannot use import statement outside a module_js_02

JS报错:Cannot use import statement outside a module_js_03