1. Before writing, there must be a sql statement for the region and generate a table
Analysis: id is the father and pid is his child, and their relationship is one-to-many. cityname is the name of the city divided into three levels of provinces, cities and counties. type represents his classification, 0 (country), 1 (province), 2 (city), 3 (county).
2. The overall code of the backend takes the pid to obtain the corresponding collection and returns to the frontend.
3. Overall front-end code
Every time the drop-down box is changed, the back-end getcity method will be called because the pid is not passed in for the first time, so the default is 1 and the first one is province, and the subsequent drop-down box changes due to the previous change.
4. Test the code, and finally test the method to see if the result is correct
5. Console output result