Vue-- define global tools

solution 

A: simple wording

Need to import each use

test.js:

Specific use

II: define a global tools (instance attribute)

The official document: https://cn.vuejs.org/v2/cookbook/adding-instance-properties.html 

 Specific use

 

Three: define global tools (plug-in)

Global registration is not required import

Examples: Now define the required tools ValidateUtil

utils/validate/index.js:

utils/index.js:

main.js:

Specific use

Reference article

https://blog.csdn.net/qq_36042938/article/details/91981643 

https://www.cnblogs.com/zhangning187/p/fendouzailushang5.html

https://blog.csdn.net/chaochao466/article/details/90479998

Released 1410 original articles · won praise 251 · views 380 000 +

Guess you like

Origin blog.csdn.net/weixin_43272781/article/details/104525389