Maps JS API Quick Start official website link
Initialization location problem
Do not be initialized onshow, onLoad in synchronization introduced api (map will not see for a long time effect, the certified results can not see), mounted in the recommended initialization.
Cannot read property ‘push’ of undefined 错误
The above error will occur in accordance with the following lines
mounted() {
var map = new AMap.Map('map_container', {
zoom: 12,
center: [120 31],
layers: [
new AMap.Marker({position: [120, 31]}),
],
});
}
The above wording to read:
mounted() {
var map = new AMap.Map('map_container', {
zoom: 12,
center: [120, 31],
});
var marker = new AMap.Marker({
position: [120, 31]
})
map.add(marker);
},
This will not go wrong!