{{ index }} {{ item }}"; 2. "wx: for-item" instruction, which can specify the variable name of the current element of the array; 3. "wx:for-index" instruction, which can specify the variable name of the current subscript of the array; 4. "wx:if" instruction; 5. Data binding instructions, etc."/> {{ index }} {{ item }}"; 2. "wx: for-item" instruction, which can specify the variable name of the current element of the array; 3. "wx:for-index" instruction, which can specify the variable name of the current subscript of the array; 4. "wx:if" instruction; 5. Data binding instructions, etc.">
search
HomeWeChat AppletMini Program DevelopmentWhat are the WeChat mini program instructions?

WeChat applet instructions include: 1. "wx:for" instruction, the usage method is such as "{{ index }} {{ item } }"; 2. "wx:for-item" instruction, which can specify the variable name of the current element of the array; 3. "wx:for-index" instruction, which can specify the variable name of the current subscript of the array; 4. " wx:if" instruction; 5. Data binding instructions, etc.

What are the WeChat mini program instructions?

The operating environment of this tutorial: Windows 10 system, WeChat applet official version 8.0.25, Dell G3 computer.

What are the WeChat mini program instructions?

WeChat Mini Program: Commonly used commands/components

1. Command

1.1 wx:for command

  • 1.1.1 html

1. There is a built-in index/item, the former index and the latter element

<view wx:for="{{ data_list }}">{{ index }} {{ item }} index索引 item元素 </view>

2. Modify

Use wx:for-item to specify the variable name of the current element of the array,

Use wx:for-index to specify the variable name of the current subscript of the array:

<view wx:for="{{array}}" wx:for-index="idx" wx:for-item="itemName">
  {{idx}}: {{itemName.message}}
</view>
  • 1.1.2 js

 data: {
    data_list:[&#39;大饼&#39;,&#39;洋葱&#39;]
  },

1.2 wx:if

In the frame, use wx:if="" to determine whether the code block needs to be rendered:

<view wx:if="{{length > 5}}"> 1 </view>
<view wx:elif="{{length > 2}}"> 2 </view>
<view wx:else> 3 </view>

1.3 block wx:if

Because wx:if is a control attribute, it needs to be added to a label.

If you want to judge multiple component tags at once, you can use a tag to wrap multiple components, and use the wx:if control attribute above.

Note: is not a component, it is just a wrapping element that will not do any rendering on the page and only accepts control attributes

<block wx:if="{{true}}">
  <view> view1 </view>
  <view> view2 </view>
</block>

1.4 Data binding

  • 1.4.1 html

<view>数据1:{{message}}</view>
  • 1.4.2 js

Page({
 
  /**
   * 页面的初始数据
   */
  data: {
    message:"新年快乐",
  }
)}

2. Component (label)

2.1 view---Similar to div

2.2 image---image

2.3 text-- -span

Recommended learning: "小program video tutorial"

The above is the detailed content of What are the WeChat mini program instructions?. For more information, please follow other related articles on the PHP Chinese website!

Statement
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
Will R.E.P.O. Have Crossplay?
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool