Bootstrap的javascript在本地工作,但在部署到服务器时则不行 [英] Bootstrap's javascript works locally but not when deployed to a server
问题描述
我下载了Twitter的bootstrap的准系统示例并对其进行了定制。我在本地进行了测试(使用WAMP服务器),一切都运行良好,包括CSS和JScript。
I downloaded the barebone example of Twitter's bootstrap and customized it. I tested it locally (with WAMP server) and everything works perfectly, both the CSS and the JScript.
我将文件上传到我的webhosting服务,而JScript只是没有工作。我注意到它是因为下拉框停止工作。
I uploaded the files to my webhosting service and the JScript just doesn't work. I noticed it because dropdown boxes stopped working.
我搜索并发现其他人有同样的问题,但他们都使用红宝石,我不是。只是bootstrap提供的CSS + JScript游戏。除此之外他们说解决方案是先包含bootstrap.js然后再包含jquery.js。好吧,我尝试了它,它没有用,我甚至包括未缩小的.js,但它仍然没有用。
I searched and found other persons with the same problem but they all are using ruby and I'm not. Just the play CSS+JScript provided by bootstrap. Besides they said the solution was to include the bootstrap.js first and then the jquery.js. Well I tried it and it didn't work, I even included the not minified .js and still it didn't work.
我使用相同的浏览器( Chrome)用于本地和远程测试。我也尝试了不同的托管服务,并且两者都出现了问题。
I'm using the same browser (Chrome) for local and remote testing. I also tried different hosting services and the problem occurred in both.
非常感谢帮助。
其他类似问题:
- Javascript features work on localhost but not when deployed to Heroku
- twitter bootstrap drop down suddenly not working
推荐答案
我知道这很奇怪,但我想我得到了解决方案。以前我使用(提供)jQuery 1.7.2缩小。现在我把它更改为使用jQuery 1.8.0而不是缩小。它刚刚开始工作......我做的另一件事是将所有文件的编码转换为UTF8(我认为这是真正的问题/解决方案)
I know this is very strange but I think I got the solution. Previously I was using the (supplied) jQuery 1.7.2 minified. Now I changed it to use the jQuery 1.8.0 not minified. It just started to work... Another thing I did was to convert all files' encoding to UTF8 (I think this was the real problem/solution)
这篇关于Bootstrap的javascript在本地工作,但在部署到服务器时则不行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!