function push() {
mvcArray.push("item");
}
function pop() {
mvcArray.pop();
}
function update() {
document.getElementById("arrLength").innerHTML = mvcArray.getLength();
}
var mvcArray = new qq.maps.MVCArray();
qq.maps.event.addListener(mvcArray, "insert_at", update);
qq.maps.event.addListener(mvcArray, "remove_at", update);
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>腾讯地图-简单地图示例</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<script charset="utf-8" src="https://map.qq.com/api/js?v=2.exp&key=OB4BZ-D4W3U-B7VVO-4PJWW-6TKDJ-WPB77"></script>
<style type="text/css">
html,
body {
height: 100%;
margin: 0px;
padding: 0px
}
</style>
</head>
<body>
<div id="container">
<div>
<input type="button" value="push" onclick="push()" />
<input type="button" value="pop" onclick="pop()" />
</div>
<div>
<span>数组长度:</span><span id="arrLength">0</span>
</div>
<div id="arrLog"></div>
</div>
<script type="text/javascript">
function push() {
mvcArray.push("item");
}
function pop() {
mvcArray.pop();
}
function update() {
document.getElementById("arrLength").innerHTML = mvcArray.getLength();
}
var mvcArray = new qq.maps.MVCArray();
qq.maps.event.addListener(mvcArray, "insert_at", update);
qq.maps.event.addListener(mvcArray, "remove_at", update);
</script>
</body>
</html>