This article mainly introduces the detailed introduction of global data, function reuse, and templates for small programs, for more information about how to define global data, function reuse, templates, and other examples of small programs, see the next article.
Summary:
1. how to define global data
In the app. data or functions defined in js App ({}) are global. you can use var app = getApp (); app on the page. function/key method, but we do not need to apply it again. defines global functions in js.
2. how to reuse code
Function reuse:
test.jstest: function(){}module.exports={ test:test }other.jsvar common = require('test.js');page({ common.test()})
Template:
Odd
Even
// Templates can be defined in other files on our page
But the import has the concept of scope, that is, only the template defined in the target file will be imported, and the template/include of the import target file will not be imported.
The entire code is introduced, which is equivalent to copying to the include position.
3. for attributes whose values are boolean type, such as the active attribute of the SS component and the checked attribute of the checkbox. Whether set to true or false, this attribute takes effect. this is also the case in html, but it can be rendered successfully by using checked =.
Thank you for reading this article. I hope it will help you. thank you for your support for this site!
The above is the details about the definition of global data, function reuse, templates, and other instances for small programs. For more information, see other related articles in the first PHP community!