Constants in the app object of the WeChat applet stepping on the pit

When doing the function of uploading pictures, you need to splice URLs. The constants of the interface have been defined in app.js:

And also in the app.js, I can directly call it in the form of URL. Just write URL splicing such as URL+'uploads/image' in the module of my after-sales upload image. It is wrong, and it will be directly reported to undifiend.

Because in other pages, this URL needs to be used as a global variable, so globalData needs to be defined in app.js

But when I call it with App.globalData.URL+'uploads/image', it reports undifined, why? Remember capitalization! The constants I defined in app.js are uppercase, but when writing to global variables, they are lowercase, so pay attention to this detail!

 

The splicing path in the above figure is correct:

Guess you like

Origin blog.csdn.net/EasyTure/article/details/109605371