我的网站在localhost上工作正常,我的
javascript正在加载并正常工作.但是当我部署网站时,脚本无法运行.当我右键单击页面并说出查看源然后查看链接的脚本文件时,它在文件的开头有一些奇怪的字符(function($){
解决方法
您必须以“UTF-8无BOM”编码重新保存文件.
您可以使用记事本或其他编辑器.
您可以使用记事本或其他编辑器.
在视觉工作室:
By default,Visual Studio uses UTF encoding with the BOM; however,you can save it to a different encoding if you’d prefer. When you go to the Save As dialog,you can expand the Save button to see the ‘Save with Encoding’ option. This will prompt you for a different encoding,and I think one of the Unicode options will leave out the BOM (somewhere in the list is UTF-8 without signature).