情景一:
var p_NormalStatus = document.getElementById("NormalStatus");//p1
var p_LockStatus = document.getElementById("LockStatus");//p2
function getData(){
p_NormalStatus.style.display = "none";//1
p_LockStatus.style.display = "block";//2
}
第一次加载页面的时候 执行getData函没问题
返回后再次进来 代码1,2都执行了,可是2个p都显示了,也就是代码没起作用;
情景二:
function getData(){
document.getElementById("NormalStatus").style.display = "none";//1
document.getElementById("LockStatus").style.display = "block";//2
}
这样就ok了!
求教大神解释下为什么会这样?!
In scenario 1, when codes 1 and 2 are executed, the page has not loaded the two DOM objects, and then cached two empty DOM objects. Naturally, there will be no value when executing getData. Moreover, your problem has nothing to do with angularjs. , do I still need to write like you do when using ng?
First of all, when you encounter a problem, you need to interrupt and check what is causing it.
Then, use classes to change the style instead of redrawing intermittently.
Finally, the specific problem and the specific environment include your loading method function. Execution environment