在一个页面引用了一个外部页面的情况下,如果两者有同名的方法,此时因为html语句使顺序加载的原因,后加载的会覆盖掉先加载的方法。
例如:
页面search.html为:
@include("./common/header.htm",{page:'/index.htm'}){}
function searchFun(){
if(!$('#kw2').val() == ''){
window.location = '${ctxPath}/search.htm?kw=' + encodeURIComponent($('#kw2').val());
}else{
window.location = '${ctxPath}/search.htm?kw=' + encodeURIComponent('');
}
}
页面header.html为:
function searchFun(){
window.location = '${ctxPath}/search.htm?kw=' + encodeURIComponent($('#kw').val());
}
此时页面search.html引入了header.html,双方都有同名的方法,根据顺序,此时调用的就是search.html的方法。