WeChat applet registers a component as a global public component

Usually, the components used by our applet need to be declared in the json file of the page corresponding to the component used,
insert image description here
but we may have some components that use Vue in many places and have Vue.use (component);
we can set it in app.json in the root directory of the applet usingComponents attribute to complete
the reference code as follows

"usingComponents": {
    
    
    "index-text": "./components/indexText"
},

In this way, he will set up a public component
insert image description here
, and then we will delete the json configuration in the original page.
insert image description here
After recompiling, we will find that the component can still be used normally
insert image description here
, so he will set up a global public component of the project.

Guess you like

Origin blog.csdn.net/weixin_45966674/article/details/132673407