In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly shows you the "sample Analysis of scope and Modularization in WeChat Mini Programs", which is easy to understand and well-organized. I hope it can help you solve your doubts. Next, let the editor lead you to study and learn the article "sample Analysis of scope and Modularization in WeChat Mini Programs".
File scope
Variables and functions declared in the JavaScript file are valid only in that file; variables and functions with the same name can be declared in different files without affecting each other.
Example:
The global application instance can be obtained through the global function getApp (). If you need global data, you can set it in App (), such as:
/ * app.js * / App ({globalData: 1}) / * a.js * / / this is the local variable localValue var localValue ='a' / / get the instance of app.js var app = getApp () / / manipulate the global variable app.globalData++/* b.js through the example of app * / / the variable localValue can be defined repeatedly in different files var localValue ='b' / / if the a.js file is executed first Then what b.js gets is the variable value console.log (getApp (). GlobalData) executed by a.js.
Modularization
We can extract some common code into a separate js file as a module. The module can expose the interface only through module.exports or exports.
Example:
/ * common.js * / function sayHello (name) {console.log (`Hello ${name}! `)} module.exports = {sayHello: sayHello}
In files that need to use these modules, use require (path) to introduce common code
/ * a.js * / var common = require ('common.js') Page ({helloMINA: function () {common.sayHello (' MINA')}}) these are all the contents of this article entitled "sample Analysis of scope and Modularization in WeChat Mini Programs". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 271
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.