Background account
Sure enough, it is not so easy, so fast the sinkhole two is thick. now I want to complete a function, mobile map Click on the button, reset the map, the question is how to add this button after the map load, otherwise the map has not been loaded, the button has appeared, click on the big problem Ah! Comrade , because I am not familiar with the API, so I do not know whether the API directly provides such a button interface, so I myself on.
Realize
To solve this problem, start by flipping through the API's documentation and looking for something like the Load event, which is certain,
The Load event has a loaded property, and the loaded property becomes true when the local graph is loaded
But how do you listen in Vue? If put in the mounted, the experiment will error, because that time the map object does not exist, not to mention the loaded attribute, how to do? See Vue's Watch function
Watch can listen to changes in the data, including the object properties, we can listen to the changes in the loaded to achieve the purpose of rendering the button at the time
- So what exactly?
- The data is modified first, the value of loaded is overloaded in the Map object, and Ishide is used to bind the button's display hidden
data () { return { map: {‘loaded‘‘‘}, true } },
watch: { ‘map.loaded‘function () { if(thistrue) { thisfalse; } } },
Summarize
This again let me toss for a while, as the saying goes, road long day will fall ~
PS: All the code in the sinkhole (a) put in the GitHub address ~ everyone choose to view
Vue-cli&webpack&arcgis API for JS Path to the sinkhole (ii)