duanhunlou7051
duanhunlou7051
2015-03-11 09:49

GO-HTML文件无法加载外部JS文件

已采纳

I have a GO project which has UI written by html. In HTML file, I have written javascript, and I can install GO and load the UI successfully.

The problem is when I move those javascript code to an external file, and include it: . I only can build GO, but when load the UI, it has error 404 Not Found which is "myscripts.js" file. The weird thing is on its header of error: Remote Address:127.0.0.1:8080 Request URL:http://localhost:8080/subscribe/myscripts.js Request Method:GET Status Code:404 Not Found

Please help, I can't find any answer yet for this

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答

  • dongsheng8664 dongsheng8664 6年前

    That's normal if you only define handler for your endpoints.

    You should add to your router the http.FileServer handler pointing to the directory that store your project files.

    Additionally, think about the <base> that to define the root of your relative links, which will prevent errors such as path nesting.

    点赞 评论 复制链接分享

相关推荐