【发布时间】:2013-03-20 10:30:48
【问题描述】:
在使用 0.7.4(也有 0.7.1)版本的 sammy.js 库时,发现如果在执行get 处理函数,控制台不会打印任何内容。
例如,在下面的代码中,sn-p 尽管没有名称为 notExistingFunction 的函数存在,但不会将任何内容打印到控制台:
<html>
<head>
...
<script src="/path/to/jquery-1.5.2.min.js"></script>
<script src="/path/to/sammy-0.7.4.min.js"></script>
...
</head>
<body>
<script>
$(document).ready(function() {
var sammy = Sammy(function() {
this.get('#someAnchor', function() {
// this function doesn't exist
notExistingFunction();
});
});
sammy.run();
// this should lead to execution of above handler
window.location.hash = '#someAnchor';
});
</script>
...
</body>
</html>
这确实使页面故障排除变得复杂,有人也遇到过这种情况吗?这是预期的行为还是错误?有什么解决方法吗?
提前非常感谢
【问题讨论】:
标签: javascript error-handling sammy.js