作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我收到此错误。
ActionController::RoutingError (No route matches [GET] "/pins/undefined"):
我已经搜索了导致此问题的代码,但看不到任何试图将用户引导至特定 URL myurl.com/pins/somethingdefinition 的内容。图像链接会导致这种情况吗?
我发现这段代码是唯一引用有关 /pins/
的内容
function constructMarker(icon){
if(icon !== 'undefined'){
return new goog.MarkerImage("/pins/" + icon,
new goog.Size(22, 38),
new goog.Point(0, 0),
new goog.Point(11, 18)
);
} else {
return new goog.MarkerImage("/pins/curve.png",
new goog.Size(22, 38),
new goog.Point(0, 0),
new goog.Point(11, 18)
);
}
}
还有这个
DOT = new goog.MarkerImage("/pins/GreenDot.png",
new goog.Size(20, 20),
new goog.Point(0, 0),
new goog.Point(10, 10));
for(var i=0; i<things.length; i++){
t = new goog.MarkerImage("/pins/" + things[i].icon,
new goog.Size(24, 50),
new goog.Point(0, 0),
new goog.Point(12, 25)
);
最佳答案
问题出在你的 JavaScript 中:
if(icon !== 'undefined'){
该测试正在寻找字符串 'undefined'
,而不是值 undefined
。也许您想检查typeof icon !== 'undefined'
。您可能可以使用更简单的 if(icon)
检查一下,因为您不太可能关心零,false
、空字符串和其他与 undefined
不同的错误值.
关于javascript - 如何找到导致 ActionController::RoutingError No Route matches 错误的原因?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51682528/
我是一名优秀的程序员,十分优秀!