且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

不允许加载本地资源

更新时间:2022-11-16 23:12:56

首先。

不要使用 file:// 加载文件。只需输入相对路径即可。
不要通过脚本标记加载javascript源地图。
您可以在和javascript文件中添加此行:
//#sourceMappingURL = / path / to / script.js.map

Do not load files with file://. Just enter the relative path. Do not load javascript source maps via the script tag. You can add this line at the and of the javascript file: //# sourceMappingURL=/path/to/script.js.map

第二。

你在快递应用程序中有这么一小段代码: app 。使用(express.static( '公共')); 。如果没有,请添加它。
服务器知道公共路径。所以你不必写 public /

You have this little line of code in you express app: app.use(express.static('public'));. If not, add it. The server knows the public path. So you don´t have to write public/

如果这是你的结构:


  • server.js

  • public /


    • index.html

    • javascripts /

    • receiver.js

    • jquery /


      • jquery-2.2.4.min.js

      • server.js
      • public/
        • index.html
        • javascripts/
        • receiver.js
        • jquery/
          • jquery-2.2.4.min.js

          将此内容写入您的html或把手文件。

          Write this into your html or handlebars file.

          <script type="text/javascript" src="javascripts/jquery/jquery-2.2.4.min.js"></script>
          <script type="text/javascript" src="javascripts/receiver.js"></script>