Home > WeChat Applet > Mini Program Development > Compilation of common problems in WeChat mini program development style

Compilation of common problems in WeChat mini program development style

巴扎黑
Release: 2017-05-21 16:26:02
Original
2915 people have browsed it

Abstract: We will encounter some common problems during the development of WeChat mini programs, and the implementation of the code is not as expected. These are all detours I have taken during the development process. I hope it will be helpful to everyone. 1. Regarding import and include, we can extract some common code into a separate js file as a ...

#
# #We will encounter some common problems during the development of WeChat applet, and the implementation of the code is not as expected. These are all detours I have taken during the development process. I hope it will be helpful to everyone.

1. About import and include

We can extract some common code into a separate js file, as a module. Modules can only expose interfaces to the outside world through module.exports or exports.

import can use the template defined by the target file in this file. But please note that import is not transitive, that is: C import B, B import A. In C, you can use the template defined by B, and in B, you can use the template defined by A, but C cannot use the template defined by A.

include can introduce the entire code except the target file, which is equivalent to copying to the include location.

Use the @import statement to import an external style sheet. @import is followed by the relative path of the external style sheet that needs to be imported, and ";" indicates the end of the statement.


2. About switchtab and navigateTo

Use switchTab to jump to pages with tabBar, and use navigateTo to jump to pages without tabBar. jump.


3. About picture size settings: Picker and picker-view

#When the swiper component is used, the image size, etc. cannot be set.

Compilation of common problems in WeChat mini program development style

Compilation of common problems in WeChat mini program development style

The above settings are invalid.

Compilation of common problems in WeChat mini program development style


This setting is valid.

The difference between Picker and picker-view is that one pops up from the bottom and the other is directly embedded inside the page

Compilation of common problems in WeChat mini program development styleCompilation of common problems in WeChat mini program development style


##4. About the difference between for navigate and redirect:

Compilation of common problems in WeChat mini program development style

Compilation of common problems in WeChat mini program development styleCompilation of common problems in WeChat mini program development style


Method of passing parameters when switching pages:

Compilation of common problems in WeChat mini program development style
Variables can be declared outside pages (global variables), and inside pages, they can be inside data or outside data.


Compilation of common problems in WeChat mini program development style







The above is the detailed content of Compilation of common problems in WeChat mini program development style. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template