我目前正在尝试用H5p-独立实现包ReactJS
下面是我的代码
import { useEffect } from "react";
import "./App.css";
import { H5P } from "h5p-standalone";
function App() {
useEffect(() => {
const el = document.getElementById("h5p-container");
const options = {
h5pJsonPath: "h5p-folder",
frameJs: "h5p-assets/frame.bundle.js",
frameCss: "h5p-assets/styles/h5p.css",
};
const h5p = new H5P(el, options);
h5p.then((res) => console.log(res)).catch((e) => console.log("Err: ", e));
}, []);
return <div id="h5p-container"></div>;
}
export default App;
但是,当我运行并检查浏览器控制台时,它显示:
Err: SyntaxError: Unexpected token '<', "<!DOCTYPE "... is not valid JSON
我做错了什么吗?
发布于 2022-10-01 10:22:22
错误消息很可能是暗示您的服务器发送的404页,只需查看您的网络选项卡即可。
我假设您没有将任何H5P内容放入h5p-folder
中,因此h5p独立文件无法找到能够说明要使用哪些资源的h5p.json
文件。
发布于 2022-10-07 11:27:24
如果您查看您的h5p json文件,它们包含以下元素“<!DOCTYPE”。
在vs代码中搜索
我就是这样解决的,因为我也犯了同样的错误。
https://stackoverflow.com/questions/73892452
复制相似问题