location.href=后面的引号一定是单引号!!
使用location.href实现页面跳转的时候,开始代码写成这样
location.href= "/templates/userMain.html";
结果浏览器跳转出来的是
报404,正确的路径本应该是http://127.0.0.1:8848/COS-UI/templates/userMain.html
我就去把location.href后的路径加了个COS-UI,写成
location.href=“COS-UI/templates/userMain.html”;
再调试,又变成这样了
给我气的,想了半天怎么也没想通
最后的解决方法是吧url的引号换成单引号写成
location.href=‘templates/userMain.html’;
页面成功显示