Native js implements code sharing at the provincial, municipal, and municipal levels,
Preface
The plug-in function only meets our business needs. If you want more functions, leave a message below and try to extend it as much as possible! If you need or like it, you can give me a star on github.
Preparation
<div id="wrap"></div>
There is no limit on the container labels on the page. You only need to give an id.
var address = new Address({ wrapId: 'wrap', showArr: ['provinces','citys','areas'], beforeCreat:function(){ console.log("beforeCreat") }, afterCreat:function(){ console.log('afterCreat'); }})
WrapId: "wrap" // here, the wrap is the id showArr of the above container: ['provinces ', 'citys ', 'areas'] // The container id of the province, city, and district respectively.
For example, if the passed Array['provinces','citys','areas']
If the length is 3, the province and city are displayed. The three strings in the array are the container IDs of the province, city, and district respectively.
For example, the passed Array['provinces','citys']
If the length is 2, the province and city are displayed. The two strings in the array are respectively the province and city container IDs.
For example, if the length of an array is 1, you can leave it empty.
beforeCreat
Callback Function executed before the plug-in is created
afterCreat
Callback Function executed after the plug-in is created
Preview
Summary
If you have any functions to add, you can leave a message in the comment area. I will try my best to satisfy them. If you have any negligence or errors, I hope you can point them out. I will modify it as soon as possible to avoid misleading others.