【发布时间】:2020-03-27 17:08:59
【问题描述】:
我刚刚开始使用 Dexie。我在尝试遵循 Consuming Dexie as a module 的简短版本示例时遇到了一个我不理解的错误。我有以下源文件:
index.html
<!DOCTYPE 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">
<title>Dexie Test</title>
<style>
</style>
</head>
<body>
<script src="./mytest.js" type="module"></script>
</body>
</html>
mydb.js
import Dexie from './dexie.js';
const db = new Dexie('myDb');
db.version(1).stores({
friends: 'name, age'
});
export default db;
mytest.js
import db from './mydb.js';
console.log(db.name);
当我从本地 Web 服务器运行此程序时,我收到以下错误:
Uncaught SyntaxError: The requested module './dexie.js' does not provide an export named 'default'
【问题讨论】:
标签: dexie