PSPDFKIT:不正确的响应MIME类型

时间:2018-08-29 17:25:03

标签: reactjs create-react-app webassembly pspdfkit

我关注了PSPDFKit React tutorials available here

我还将文件复制到/ public目录,并将pspdfkit.js以外的所有内容都从(120) > 01:20移到了该目录,并更新了node_modules变量以指向该目录。

然后,当我尝试在baseUrl上使用npm run start在本地运行我的应用程序时,我从PSPDFkit获得了加载动画,但是它挂断了,并且控制台给了我一个错误:

  

使用WASM方法

     

开始http://localhost:3000/pspdfkit-lib/pspdfkit.wasm下载。

     

未捕获(承诺)TypeError:无法在'WebAssembly'上执行'compile':错误的响应MIME类型。预期的“申请/数量”。

I know there is a trouble-shooting topic on it, found here,但我仍然无法解决我的问题。

有什么想法吗?

我的组件文件:

localhost:3000

2 个答案:

答案 0 :(得分:1)

对于遇到相同问题的任何人。您可能通过禁用Web程序集流来获取(这会导致错误。react-scripts webpack不会以正确的mime类型提供wasm文件)。 只需在load方法上将disableWebAssemblyStreaming传递为true:

'<t:ItemClass>IPM.Note</t:ItemClass>'

答案 1 :(得分:0)

问题似乎是由于wasm文件未按正确的内容类型提供,如此处建议的那样:https://pspdfkit.com/guides/web/current/pspdfkit-for-web/troubleshooting/#response-has-unsupported-mime-type-error

打开var arrayOfObject = [{ "item": { "this": "is", "that": "is" } }, { "item2": { "this": "is", "that": "is" } }]; var itemObject = {}; arrayOfObject.forEach(function(value) { var filterObject = Object.keys(value).filter(val => val.indexOf("item") != -1); if (filterObject.length > 0) { filterObject.forEach(key => { itemObject[key] = itemObject[key] || []; itemObject[key].push(value[filterObject[0]]); }); } }); console.log(itemObject.item); //item console.log(itemObject.item2); //item文件并将package.json升级到react-scripts,删除1.1.5,然后重新安装。

将来,请与pspdfkit.com/support/request联系,我们的支持团队将为您提供帮助。