我想对JSON文件使用ES6导出/导入
// ui.js
import sampleData from '../data/sample-data.json';
export function initUI() {
console.log(sampleData)
}
我有一个烧瓶应用程序,在main.py
我添加了以下内容(我还尝试切换顺序)
mimetypes.add_type('application/json', ".json", strict=True)
mimetypes.add_type('application/javascript', ".js", strict=True)
这只适用于JS文件。对于JSON导入,我得到以下错误
Failed to load module script: The server responded with a non-JavaScript MIME type of "application/json". Strict MIME type checking is enforced for module scripts per HTML spec.
我的想法是因为json
有前缀js
。因此,所有json
导入都被视为.js
文件
我怎样才能解决这个问题
目前没有回答
相关问题 更多 >
编程相关推荐