我花了几个小时试图找到解决这个问题的方法,但这非常困难。我已经阅读了https://github.com/bminer/node-blade#simple-example上的安装说明和示例,但似乎无法加载客户端刀片模板。
这是我所做的。
我在 /views/template.blade 的公共静态服务器中有一个客户端模板。
我已经拉入刀片“runtime.js”文件并将其包含在 html 正文底部的脚本标记中。
在我的 main.js 文件中,我试图简单地运行代码:
blade.Runtime.loadTemplate("template.blade", function(err, tmpl){
console.dir(err, tmpl);
});
我已经验证它可以正确访问 template.blade 文件,因为它位于可从 Chrome 开发工具查看的页面源代码中。此外,如果我将上述参数更改为“templateXYX.blade”,我会收到 404 错误。
然而我无法绕过这个错误:
Uncaught SyntaxError: Unexpected token default template.blade:1
在不同的测试排列过程中,我还收到以下错误:
Resource interpreted as Script but transferred with MIME type application/octet-stream: "http://localhost:3005/views/template.blade".
从节点刀片说明中,我无法理解是否缺少任何设置。
知道为什么blade.Runtime.loadTemplate 在读取template.blade 文件时会抛出此错误吗?就像它试图将 .blade 文件作为 javascript 文件读取并且无法解析它一样?
感谢您提供任何线索。