監聽改變全局變量,別的文件沒有接收到新的值

爲何個人項目裏index_new.js中的helpinfo值改變了,可是index.js的值並不會變呢?,可是下面的是OK的html

main.asphtml5

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>iBall Baton Wireless-N Router</title>
<!--[if lt IE 9]>
<script src="js/libs/html5shiv.min.js"></script>
<script src="js/libs/respond.min.js"></script>
  <![endif]-->
</head>
<button id="jump-wan">jump-wan</button>
<button id="navbar-button">navbar-button</button>
<body>
<script src="./jquery.js"></script>
<script src="./index_new.js"></script>
<script src="./index.js"></script>
</body>
</html>

複製代碼

js/index_new.jsjquery

var helpinfo={"test":"test"}
var n=0


function handle(topNavId,subNavId){
    info={"a":n+1}
    return info
}
$(function() {
    $('#jump-wan').on('click',function(e){
        window.helpinfo = handle('base_config','m-WAN')
        console.log(window.helpinfo)

    })
    
    console.log(window.helpinfo) 
});


複製代碼

js/index.jsbash

$(function() {

	$("#navbar-button").on("click", function () {
        console.log(window.helpinfo) 
	});
	
});


複製代碼
相關文章
相關標籤/搜索