我在使用bootstrap的过程当中发现,使用的他的modal的过程当中.若是我弹出一个modal.而后再这个modal中再次触发新的modal.bootstrap就陷入了无穷循环了.这样会致使没法多重使用modal.估计是bootstrap的一个bug. 首先咱们要本身制造异常.而后用相关代码快速解决异常.
//第一种方式
Math.power = Math.pow;
Math.pow = function(x, y) {
if (x != 0) {
return Math.power(x, y);
} else {
return 0;
}
}
//if (Math.power == null) { //Solution: 若是Math.power 已经在别的地方定义过了,再次这样从新定义,会致使循环引用
Math.power = Math.pow;
Math.pow = function(x, y) {
if (x != 0) {
return Math.power(x, y);
} else {
return 0;
}
}
//}
//第二种方式
Math.power = Math.pow;
Math.pow = function(x, y) {
if (x != 0) {
return Math.pow(x, y);
//return Math.power(x, y);//Solution:启用这句能够解决问题.
} else {
return 0;
}
}
上面我写了两种方式来制造这种异常.而后把里面注释的语句启用.就能够避免这种异常.