削你飞刀 發表於 2023-4-19 16:19:00

微信小程序开发学习笔记(二)——小程序框架、组件、WXML

<h1>一、整体认识小程序框架</h1>
<p>小程序开发框架的目标是通过尽可能简单、高效的方式让开发者可以在微信中开发具有原生 APP 体验的服务。</p>
<p>整个小程序框架系统分为两部分:<strong>逻辑层</strong>(App Service)和&nbsp;<strong>视图层</strong>(View)。小程序提供了自己的视图层描述语言&nbsp;<code>WXML</code>&nbsp;和&nbsp;<code>WXSS</code>,以及基于&nbsp;<code>JavaScript</code>&nbsp;的逻辑层框架,并在视图层与逻辑层间提供了数据传输和事件系统,让开发者能够专注于数据与逻辑。</p>
<h2 id="响应的数据绑定">1.1、响应的数据绑定</h2>
<p>框架的核心是一个响应的数据绑定系统,可以让数据与视图非常简单地保持同步。当做数据修改的时候,只需要在逻辑层修改数据,视图层就会做相应的更新。</p>
<p>通过这个简单的例子来看:</p>
<p>在开发者工具中预览效果</p>
<div class="language-html extra-class">
<pre class="language-html"><code><span class="token comment">&lt;!-- This is our View --&gt;
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;view<span class="token punctuation">&gt; Hello {{name}}! <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/view<span class="token punctuation">&gt;
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;button <span class="token attr-name">bindtap<span class="token attr-value"><span class="token punctuation attr-equals">=<span class="token punctuation">"changeName<span class="token punctuation">"<span class="token punctuation">&gt; Click me! <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/button<span class="token punctuation">&gt;
</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></code></pre>
</div>
<div class="language-js extra-class">
<pre class="language-js"><code><span class="token comment">// This is our App Service.
<span class="token comment">// This is our data.
<span class="token keyword">var helloData <span class="token operator">= <span class="token punctuation">{
name<span class="token operator">: <span class="token string">'Weixin'
<span class="token punctuation">}

<span class="token comment">// Register a Page.
<span class="token function">Page<span class="token punctuation">(<span class="token punctuation">{
data<span class="token operator">: helloData<span class="token punctuation">,
<span class="token function-variable function">changeName<span class="token operator">: <span class="token keyword">function<span class="token punctuation">(<span class="token parameter">e<span class="token punctuation">) <span class="token punctuation">{
    <span class="token comment">// sent data change to view
    <span class="token keyword">this<span class="token punctuation">.<span class="token function">setData<span class="token punctuation">(<span class="token punctuation">{
      name<span class="token operator">: <span class="token string">'MINA'
    <span class="token punctuation">}<span class="token punctuation">)
<span class="token punctuation">}
<span class="token punctuation">}<span class="token punctuation">)
</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></code></pre>
</div>
<ul>
<li>开发者通过框架将逻辑层数据中的&nbsp;<code>name</code>&nbsp;与视图层的&nbsp;<code>name</code>&nbsp;进行了绑定,所以在页面一打开的时候会显示&nbsp;<code>Hello Weixin!</code>;</li>
<li>当点击按钮的时候,视图层会发送&nbsp;<code>changeName</code>&nbsp;的事件给逻辑层,逻辑层找到并执行对应的事件处理函数;</li>
<li>回调函数触发后,逻辑层执行&nbsp;<code>setData</code>&nbsp;的操作,将&nbsp;<code>data</code>&nbsp;中的&nbsp;<code>name</code>&nbsp;从&nbsp;<code>Weixin</code>&nbsp;变为&nbsp;<code>MINA</code>,因为该数据和视图层已经绑定了,从而视图层会自动改变为&nbsp;<code>Hello MINA!</code>。</li>
</ul>
<p>pages/counter/index.wxml</p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 128, 0, 1)">&lt;!--</span><span style="color: rgba(0, 128, 0, 1)">pages/counter/index.wxml</span><span style="color: rgba(0, 128, 0, 1)">--&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">view </span><span style="color: rgba(255, 0, 0, 1)">class</span><span style="color: rgba(0, 0, 255, 1)">="counter"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">view </span><span style="color: rgba(255, 0, 0, 1)">class</span><span style="color: rgba(0, 0, 255, 1)">="title"</span><span style="color: rgba(0, 0, 255, 1)">&gt;&lt;</span><span style="color: rgba(128, 0, 0, 1)">text</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>计数器<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">text</span><span style="color: rgba(0, 0, 255, 1)">&gt;&lt;/</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>{{count}}<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">button </span><span style="color: rgba(255, 0, 0, 1)">type</span><span style="color: rgba(0, 0, 255, 1)">="primary"</span><span style="color: rgba(255, 0, 0, 1)"> bindtap</span><span style="color: rgba(0, 0, 255, 1)">="onCount"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>点击count++<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">button</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span></pre>
</div>
<p>pages/counter/index.wxss</p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 128, 0, 1)">/*</span><span style="color: rgba(0, 128, 0, 1)"> pages/counter/index.wxss </span><span style="color: rgba(0, 128, 0, 1)">*/</span><span style="color: rgba(128, 0, 0, 1)">

.counter
</span>{<span style="color: rgba(255, 0, 0, 1)">
font-size</span>:<span style="color: rgba(0, 0, 255, 1)"> 60rpx</span>;<span style="color: rgba(255, 0, 0, 1)">
text-align</span>:<span style="color: rgba(0, 0, 255, 1)"> center</span>;<span style="color: rgba(255, 0, 0, 1)">
padding</span>:<span style="color: rgba(0, 0, 255, 1)"> 30rpx</span>;
}<span style="color: rgba(128, 0, 0, 1)">

.counter view</span>{<span style="color: rgba(255, 0, 0, 1)">
margin</span>:<span style="color: rgba(0, 0, 255, 1)"> 20rpx 0</span>;
}<span style="color: rgba(128, 0, 0, 1)">

.counter .title</span>{<span style="color: rgba(255, 0, 0, 1)">
color</span>:<span style="color: rgba(0, 0, 255, 1)">red</span>;
}</pre>
</div>
<p>pages/counter/index.js</p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> pages/counter/index.js</span>
<span style="color: rgba(0, 0, 0, 1)">Page({
</span><span style="color: rgba(0, 128, 0, 1)">/*</span><span style="color: rgba(0, 128, 0, 1)">*
   * 页面的初始数据
   </span><span style="color: rgba(0, 128, 0, 1)">*/</span><span style="color: rgba(0, 0, 0, 1)">
data: {
    count:</span>100<span style="color: rgba(0, 0, 0, 1)">
},
onCount(){
    </span><span style="color: rgba(0, 0, 255, 1)">this</span>.setData({count:<span style="color: rgba(0, 0, 255, 1)">this</span>.data.count+1<span style="color: rgba(0, 0, 0, 1)">});
}
})</span></pre>
</div>
<p>运行效果:</p>
<p><img src="https://img2023.cnblogs.com/blog/63651/202304/63651-20230419091251486-121540783.png" alt="" width="319" height="554" loading="lazy"></p>
<h2 id="页面管理">1.2、页面管理</h2>
<p>框架 管理了整个<strong>小程序</strong>的页面路由,可以做到页面间的无缝切换,并给以页面完整的生命周期。开发者需要做的只是将页面的数据、方法、生命周期函数注册到 框架 中,其他的一切复杂的操作都交由 框架 处理。</p>
<h2 id="基础组件">1.3、基础组件</h2>
<p>框架 提供了一套基础的组件,这些组件自带微信风格的样式以及特殊的逻辑,开发者可以通过组合基础组件,创建出强大的<strong>微信小程序</strong>&nbsp;。</p>
<h2 id="丰富的-API">1.4、丰富的 API</h2>
<p>框架 提供丰富的微信原生 API,可以方便的调起微信提供的能力,如获取用户信息,本地存储,支付功能等。</p>
<h2 id="51-小程序文件结构和传统web对比">1.5. 小程序文件结构和传统web对比<button class="cnblogs-toc-button" title="显示目录导航"></button></h2>
<div class="table-wrapper">
<table>
<thead>
<tr><th>结构</th><th>传统web</th><th>微信小程序</th></tr>
</thead>
<tbody>
<tr>
<td>结构</td>
<td>HTML</td>
<td>WXML</td>
</tr>
<tr>
<td>样式</td>
<td>CSS</td>
<td>WXSS</td>
</tr>
<tr>
<td>逻辑</td>
<td>Javascript</td>
<td>Javascript</td>
</tr>
<tr>
<td>配置</td>
<td>无</td>
<td>JSON</td>
</tr>
</tbody>
</table>
</div>
<p>通过以上对比得出,传统web&nbsp;是三层结构。而微信小程序 是四层结构,多了一层&nbsp;配置.json</p>
<h1>二、组件</h1>
<p>小程序中的组件是由宿主环境提供的,主要分为9大类:</p>
<p>视图容器、基础内容、表单组件、导航组件、媒体组件、map地图组件、canvas画布组件、开放能力、无障碍访问</p>
<p><img src="https://img2023.cnblogs.com/blog/63651/202304/63651-20230418114333011-1207704452.png" alt="" width="853" height="496" loading="lazy"></p>
<p><img src="https://img2023.cnblogs.com/blog/63651/202304/63651-20230419093010580-1373824095.png" alt="" loading="lazy"></p>
<h2>2.0、单位</h2>
<h3>2.0.1、响应式单位rpx</h3>
<p>在使用 CSS 进行移动端的网页开发时,由于不同手机设备的屏幕比,在换算像素单位时会遇到很多麻烦。为了方便开发人员适配各种屏幕WxSS 中加入了新的尺寸单位 rpx 即(responsive pixel,响应式像素)。</p>
<p>rpx 说明</p>
<p><span style="color: rgba(255, 0, 0, 1)">rpx: 规定不管屏幕为多少px , 100%的屏幕宽度就是750rpx</span></p>
<p>100% 屏幕的宽度 = 750rpx</p>
<p>rpx响应单位</p>
<ul>
<li>
<p>rpx是微信小程序独有的,解决屏幕自适应的尺寸单位</p>
</li>
<li>
<p>可以根据屏幕宽度进行自适应,不论大小屏幕,规定屏幕宽为750rpx</p>
</li>
<li>
<p>通过 rpx 设置元素和字体的大小,小程序在不同尺寸的屏幕下,可以实现自动适配</p>
</li>
</ul>
<p>rpx 和 px之间的换算</p>
<ul>
<li>
<p>在普通网页开发中 , 最常见的像素单位是px</p>
</li>
<li>
<p>在小程序开发中推荐使用 rpx这种响应式的像素单位进行开发</p>
</li>
<li>
<p>如在 iPhone6 上,屏幕宽度为375px,共有750个物理像素,则750rpx = 375px = 750物理像素,1rpx = 0.5px</p>
</li>
</ul>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">view </span><span style="color: rgba(255, 0, 0, 1)">class</span><span style="color: rgba(0, 0, 255, 1)">="rpxDemo"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span><span style="color: rgba(0, 0, 0, 1)">
Hello rpx!
</span><span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span></pre>
</div>
<div class="cnblogs_code">
<pre><span style="color: rgba(128, 0, 0, 1)">.rpxDemo
</span>{<span style="color: rgba(255, 0, 0, 1)">
width</span>:<span style="color: rgba(0, 0, 255, 1)"> 375rpx</span>;<span style="color: rgba(255, 0, 0, 1)">
height</span>:<span style="color: rgba(0, 0, 255, 1)"> 375rpx</span>;<span style="color: rgba(255, 0, 0, 1)">
background</span>:<span style="color: rgba(0, 0, 255, 1)"> yellow</span>;<span style="color: rgba(255, 0, 0, 1)">
font-size</span>:<span style="color: rgba(0, 0, 255, 1)">80rpx</span>;
}</pre>
</div>
<p>运行在iphone5上:</p>
<p><img src="https://img2023.cnblogs.com/blog/63651/202304/63651-20230419093837042-1355025402.png" alt="" loading="lazy"></p>
<p>&nbsp;更大屏幕的iphone6</p>
<p><img src="https://img2023.cnblogs.com/blog/63651/202304/63651-20230419093911130-1718549143.png" alt="" loading="lazy"></p>
<p>&nbsp;字体与view都相应响应式变大。</p>
<h3>2.0.2、其它单位</h3>
<p>px&nbsp;绝对单位,页面按精确像素展示</p>
<p>em&nbsp;相对单位,相对于它的父节点字体进行计算</p>
<p>rem&nbsp;相对单位,相对根节点html的字体大小来计算</p>
<p>%&nbsp;一般来说就是相对于父元素</p>
<p>vh&nbsp;视窗高度,1vh等于视窗高度的1%</p>
<p>vw&nbsp;视窗宽度,1vw等于视窗宽度的1%</p>
<div class="cnblogs_code">
<pre><span style="color: rgba(128, 0, 0, 1)">.box
</span>{<span style="color: rgba(255, 0, 0, 1)">
display</span>:<span style="color: rgba(0, 0, 255, 1)">flex</span>;<span style="color: rgba(255, 0, 0, 1)">
justify-content</span>:<span style="color: rgba(0, 0, 255, 1)"> center</span>;<span style="color: rgba(255, 0, 0, 1)">
align-items</span>:<span style="color: rgba(0, 0, 255, 1)"> center</span>;<span style="color: rgba(255, 0, 0, 1)">
height</span>:<span style="color: rgba(0, 0, 255, 1)"> 100vh</span>;
}<span style="color: rgba(128, 0, 0, 1)">

.box view</span>{<span style="color: rgba(255, 0, 0, 1)">
background</span>:<span style="color: rgba(0, 0, 255, 1)"> lightcoral</span>;<span style="color: rgba(255, 0, 0, 1)">
height</span>:<span style="color: rgba(0, 0, 255, 1)"> 50vh</span>;<span style="color: rgba(255, 0, 0, 1)">
line-height</span>:<span style="color: rgba(0, 0, 255, 1)"> 50vh</span>;<span style="color: rgba(255, 0, 0, 1)">
width</span>:<span style="color: rgba(0, 0, 255, 1)"> 50vw</span>;<span style="color: rgba(255, 0, 0, 1)">
text-align</span>:<span style="color: rgba(0, 0, 255, 1)"> center</span>;
}</pre>
</div>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">view </span><span style="color: rgba(255, 0, 0, 1)">class</span><span style="color: rgba(0, 0, 255, 1)">="box"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span><span style="color: rgba(0, 0, 0, 1)">
    Hello rpx!
</span><span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span></pre>
</div>
<p><img src="https://img2023.cnblogs.com/blog/63651/202304/63651-20230418153601608-1541725219.png" alt="" width="369" height="641" loading="lazy"></p>
<p>示例2:</p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">view </span><span style="color: rgba(255, 0, 0, 1)">class</span><span style="color: rgba(0, 0, 255, 1)">="mybox"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">view </span><span style="color: rgba(255, 0, 0, 1)">class</span><span style="color: rgba(0, 0, 255, 1)">="demo"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span><span style="color: rgba(0, 0, 0, 1)">
    Hello Applet!
</span><span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span></pre>
</div>
<div class="cnblogs_code">
<pre><span style="color: rgba(128, 0, 0, 1)">.mybox
</span>{<span style="color: rgba(255, 0, 0, 1)">
display</span>:<span style="color: rgba(0, 0, 255, 1)"> flex</span>;<span style="color: rgba(255, 0, 0, 1)">
justify-content</span>:<span style="color: rgba(0, 0, 255, 1)"> center</span>;<span style="color: rgba(255, 0, 0, 1)">
align-items</span>:<span style="color: rgba(0, 0, 255, 1)"> center</span>;<span style="color: rgba(255, 0, 0, 1)">
background</span>:<span style="color: rgba(0, 0, 255, 1)"> gray</span>;<span style="color: rgba(255, 0, 0, 1)">
height</span>:<span style="color: rgba(0, 0, 255, 1)"> 100vh</span>;
}<span style="color: rgba(128, 0, 0, 1)">
.demo</span>{<span style="color: rgba(255, 0, 0, 1)">
background</span>:<span style="color: rgba(0, 0, 255, 1)"> oldlace</span>;<span style="color: rgba(255, 0, 0, 1)">
width</span>:<span style="color: rgba(0, 0, 255, 1)"> 50vw</span>;<span style="color: rgba(255, 0, 0, 1)">
height</span>:<span style="color: rgba(0, 0, 255, 1)"> 50vh</span>;<span style="color: rgba(255, 0, 0, 1)">
text-align</span>:<span style="color: rgba(0, 0, 255, 1)"> center</span>;<span style="color: rgba(255, 0, 0, 1)">
line-height</span>:<span style="color: rgba(0, 0, 255, 1)"> 50vh</span>;<span style="color: rgba(255, 0, 0, 1)">
font-size</span>:<span style="color: rgba(0, 0, 255, 1)"> 7vw</span>;
}</pre>
</div>
<p>运行效果:</p>
<p><img src="https://img2023.cnblogs.com/blog/63651/202304/63651-20230419094705126-324359354.png" alt="" width="367" height="629" loading="lazy"></p>
<h2>2.1、view组件</h2>
<p><span style="font-size: 15px">在微信小程序开发中,view就相当于html5中的div,也是块状元素</span></p>
<p><span style="font-size: 15px"> 官方文档给出的解释呢就是:视图容器</span></p>
<p><span style="font-size: 15px">我们在编写html5页面所用的div呢,在开发小程序中就改成view即可</span></p>
<p><strong><span style="font-size: 15px">属性说明:</span></strong></p>
<div class="table-wrp">
<table>
<thead>
<tr><th>属性</th><th>类型</th><th>默认值</th><th>必填</th><th>说明</th><th>最低版本</th></tr>
</thead>
<tbody>
<tr>
<td>hover-class</td>
<td>string</td>
<td>none</td>
<td>否</td>
<td>指定按下去的样式类。当&nbsp;<code>hover-class="none"</code>&nbsp;时,没有点击态效果</td>
<td>1.0.0</td>
</tr>
<tr>
<td>hover-stop-propagation</td>
<td>boolean</td>
<td>false</td>
<td>否</td>
<td>指定是否阻止本节点的祖先节点出现点击态</td>
<td>1.5.0</td>
</tr>
<tr>
<td>hover-start-time</td>
<td>number</td>
<td>50</td>
<td>否</td>
<td>按住后多久出现点击态,单位毫秒</td>
<td>1.0.0</td>
</tr>
<tr>
<td>hover-stay-time</td>
<td>number</td>
<td>400</td>
<td>否</td>
<td>手指松开后点击态保留时间,单位毫秒</td>
<td>1.0.0</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
</div>
<p>&nbsp;</p>
<div class="table-wrp">
<p><img src="https://img2023.cnblogs.com/blog/2401301/202301/2401301-20230102160443614-617181537.png" alt="" width="258" height="84" loading="lazy"></p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>Hello wx<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span></pre>
</div>
</div>
<p><span style="font-size: 18.6667px; color: rgba(255, 0, 0, 1)">view类似div,这里主要学会使用view+flex布局&nbsp;https://www.cnblogs.com/best/p/6136165.html#_label1</span></p>
<p>示例:</p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">view </span><span style="color: rgba(255, 0, 0, 1)">hover-class</span><span style="color: rgba(0, 0, 255, 1)">="bgcolor"</span><span style="color: rgba(255, 0, 0, 1)"> class</span><span style="color: rgba(0, 0, 255, 1)">="box"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>Tom<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>Jack<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>Rose<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span></pre>
</div>
<div class="cnblogs_code">
<pre><span style="color: rgba(128, 0, 0, 1)">.bgcolor</span>{<span style="color: rgba(255, 0, 0, 1)">
background</span>:<span style="color: rgba(0, 0, 255, 1)"> lightcyan</span>;
}<span style="color: rgba(128, 0, 0, 1)">
.box</span>{<span style="color: rgba(255, 0, 0, 1)">
display</span>:<span style="color: rgba(0, 0, 255, 1)"> flex</span>;<span style="color: rgba(255, 0, 0, 1)">
flex-direction</span>:<span style="color: rgba(0, 0, 255, 1)"> row</span>;<span style="color: rgba(255, 0, 0, 1)">
background</span>:<span style="color: rgba(0, 0, 255, 1)"> oldlace</span>;<span style="color: rgba(255, 0, 0, 1)">
justify-content</span>:<span style="color: rgba(0, 0, 255, 1)">space-around
</span>}<span style="color: rgba(128, 0, 0, 1)">

.box view</span>{<span style="color: rgba(255, 0, 0, 1)">
height</span>:<span style="color: rgba(0, 0, 255, 1)"> 80rpx</span>;<span style="color: rgba(255, 0, 0, 1)">
line-height</span>:<span style="color: rgba(0, 0, 255, 1)"> 80rpx</span>;<span style="color: rgba(255, 0, 0, 1)">
text-align</span>:<span style="color: rgba(0, 0, 255, 1)"> center</span>;
}<span style="color: rgba(128, 0, 0, 1)">

.box view:nth-child(1)</span>{<span style="color: rgba(255, 0, 0, 1)">
background</span>:<span style="color: rgba(0, 0, 255, 1)"> #ddeeff</span>;
}<span style="color: rgba(128, 0, 0, 1)">
.box view:nth-child(2)</span>{<span style="color: rgba(255, 0, 0, 1)">
background</span>:<span style="color: rgba(0, 0, 255, 1)"> #99ddee</span>;<span style="color: rgba(255, 0, 0, 1)">
width</span>:<span style="color: rgba(0, 0, 255, 1)"> 200rpx</span>;
}<span style="color: rgba(128, 0, 0, 1)">
.box view:nth-child(3)</span>{<span style="color: rgba(255, 0, 0, 1)">
background</span>:<span style="color: rgba(0, 0, 255, 1)"> #6699dd</span>;
}</pre>
</div>
<p>结果:</p>
<p><img src="https://img2023.cnblogs.com/blog/63651/202304/63651-20230419162140909-1162785815.png" alt="" loading="lazy"></p>
<p>示例:</p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">view </span><span style="color: rgba(255, 0, 0, 1)">hover-class</span><span style="color: rgba(0, 0, 255, 1)">="bgcolor"</span><span style="color: rgba(255, 0, 0, 1)"> class</span><span style="color: rgba(0, 0, 255, 1)">="box"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>Tom<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>Jack<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>Rose<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span></pre>
</div>
<div class="cnblogs_code">
<pre><span style="color: rgba(128, 0, 0, 1)">.bgcolor</span>{<span style="color: rgba(255, 0, 0, 1)">
background</span>:<span style="color: rgba(0, 0, 255, 1)"> lightcyan</span>;
}<span style="color: rgba(128, 0, 0, 1)">
.box</span>{<span style="color: rgba(255, 0, 0, 1)">
display</span>:<span style="color: rgba(0, 0, 255, 1)"> flex</span>;<span style="color: rgba(255, 0, 0, 1)">
flex-direction</span>:<span style="color: rgba(0, 0, 255, 1)"> row</span>;<span style="color: rgba(255, 0, 0, 1)">
background</span>:<span style="color: rgba(0, 0, 255, 1)"> oldlace</span>;<span style="color: rgba(255, 0, 0, 1)">
height</span>:<span style="color: rgba(0, 0, 255, 1)"> 50vh</span>;
<span style="color: rgba(0, 128, 0, 1)">/*</span><span style="color: rgba(0, 128, 0, 1)"> align-items: flex-end; </span><span style="color: rgba(0, 128, 0, 1)">*/</span>
<span style="color: rgba(0, 128, 0, 1)">/*</span><span style="color: rgba(0, 128, 0, 1)"> align-items: flex-start; </span><span style="color: rgba(0, 128, 0, 1)">*/</span>
<span style="color: rgba(0, 128, 0, 1)">/*</span><span style="color: rgba(0, 128, 0, 1)"> align-items:center; </span><span style="color: rgba(0, 128, 0, 1)">*/</span>
<span style="color: rgba(0, 128, 0, 1)">/*</span><span style="color: rgba(0, 128, 0, 1)"> align-items: stretch; </span><span style="color: rgba(0, 128, 0, 1)">*/</span><span style="color: rgba(255, 0, 0, 1)">
align-items</span>:<span style="color: rgba(0, 0, 255, 1)"> baseline</span>;
}<span style="color: rgba(128, 0, 0, 1)">

.box view</span>{<span style="color: rgba(255, 0, 0, 1)">
height</span>:<span style="color: rgba(0, 0, 255, 1)"> 80rpx</span>;<span style="color: rgba(255, 0, 0, 1)">
text-align</span>:<span style="color: rgba(0, 0, 255, 1)"> center</span>;
}<span style="color: rgba(128, 0, 0, 1)">

.box view:nth-child(1)</span>{<span style="color: rgba(255, 0, 0, 1)">
background</span>:<span style="color: rgba(0, 0, 255, 1)"> #ddeeff</span>;
}<span style="color: rgba(128, 0, 0, 1)">
.box view:nth-child(2)</span>{<span style="color: rgba(255, 0, 0, 1)">
background</span>:<span style="color: rgba(0, 0, 255, 1)"> #99ddee</span>;<span style="color: rgba(255, 0, 0, 1)">
width</span>:<span style="color: rgba(0, 0, 255, 1)"> 200rpx</span>;<span style="color: rgba(255, 0, 0, 1)">
font-size</span>:<span style="color: rgba(0, 0, 255, 1)"> 100rpx</span>;
}<span style="color: rgba(128, 0, 0, 1)">
.box view:nth-child(3)</span>{<span style="color: rgba(255, 0, 0, 1)">
background</span>:<span style="color: rgba(0, 0, 255, 1)"> #6699dd</span>;
}</pre>
</div>
<p>结果:</p>
<p><img src="https://img2023.cnblogs.com/blog/63651/202304/63651-20230420084610561-1346904851.png" alt="" width="316" height="551" loading="lazy"></p>
<p>示例:</p>
<div class="cnblogs_code">
<pre><span style="color: rgba(128, 0, 0, 1)">.bgcolor</span>{<span style="color: rgba(255, 0, 0, 1)">
background</span>:<span style="color: rgba(0, 0, 255, 1)"> lightcyan</span>;
}<span style="color: rgba(128, 0, 0, 1)">
.box</span>{<span style="color: rgba(255, 0, 0, 1)">
display</span>:<span style="color: rgba(0, 0, 255, 1)"> flex</span>;<span style="color: rgba(255, 0, 0, 1)">
flex-direction</span>:<span style="color: rgba(0, 0, 255, 1)"> row</span>;<span style="color: rgba(255, 0, 0, 1)">
background</span>:<span style="color: rgba(0, 0, 255, 1)"> oldlace</span>;<span style="color: rgba(255, 0, 0, 1)">
height</span>:<span style="color: rgba(0, 0, 255, 1)"> 50vh</span>;
}<span style="color: rgba(128, 0, 0, 1)">

.box view</span>{<span style="color: rgba(255, 0, 0, 1)">
height</span>:<span style="color: rgba(0, 0, 255, 1)"> 80rpx</span>;<span style="color: rgba(255, 0, 0, 1)">
text-align</span>:<span style="color: rgba(0, 0, 255, 1)"> center</span>;
}<span style="color: rgba(128, 0, 0, 1)">

.box view:nth-child(1)</span>{<span style="color: rgba(255, 0, 0, 1)">
background</span>:<span style="color: rgba(0, 0, 255, 1)"> #ddeeff</span>;<span style="color: rgba(255, 0, 0, 1)">
flex-grow</span>:<span style="color: rgba(0, 0, 255, 1)"> 0</span>;
}<span style="color: rgba(128, 0, 0, 1)">
.box view:nth-child(2)</span>{<span style="color: rgba(255, 0, 0, 1)">
background</span>:<span style="color: rgba(0, 0, 255, 1)"> #99ddee</span>;<span style="color: rgba(255, 0, 0, 1)">
flex-grow</span>:<span style="color: rgba(0, 0, 255, 1)"> 1</span>;
}<span style="color: rgba(128, 0, 0, 1)">
.box view:nth-child(3)</span>{<span style="color: rgba(255, 0, 0, 1)">
background</span>:<span style="color: rgba(0, 0, 255, 1)"> #6699dd</span>;<span style="color: rgba(255, 0, 0, 1)">
flex-grow</span>:<span style="color: rgba(0, 0, 255, 1)"> 0</span>;
}</pre>
</div>
<p>结果:</p>
<p><img src="https://img2023.cnblogs.com/blog/63651/202304/63651-20230420090015487-1938916428.png" alt="" width="366" height="643" loading="lazy"></p>
<h2><span style="font-size: 14pt"><strong>2.2、scroll-view</strong></span></h2>
<p><span style="font-size: 15px">可滚动视图区域。使用竖向滚动时,需要给scroll-view一个固定高度</span></p>
<p><span style="font-size: 15px">说白了其实就是一个可以 允许滚动的容器,只需要设置最大高度即可</span></p>
<p><strong><span style="font-size: 15px">属性说明:</span></strong></p>
<div class="table-wrp webview-table" style="margin: 1em 0 3em; padding: 0; -webkit-tap-highlight-color: transparent; overflow-x: auto; max-width: 100%; color: rgba(34, 34, 34, 1); font-family: -apple-system, BlinkMacSystemFont, &quot;SF UI Text&quot;, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif">
<table class="have-children-table" style="margin-right: 0; margin-left: 0; padding: 0; -webkit-tap-highlight-color: transparent; width: 694px; border-spacing: 0; overflow: auto; font-size: 14px; height: 2273px">
<thead style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent"><th style="margin: 0; padding: 10px 20px 10px 0; -webkit-tap-highlight-color: transparent; text-align: left; border-bottom-color: rgba(136, 136, 136, 1); white-space: nowrap; color: rgba(136, 136, 136, 1)">属性</th><th style="margin: 0; padding: 10px 20px; -webkit-tap-highlight-color: transparent; text-align: left; border-bottom-color: rgba(136, 136, 136, 1); white-space: nowrap; color: rgba(136, 136, 136, 1)">类型</th><th style="margin: 0; padding: 10px 20px; -webkit-tap-highlight-color: transparent; text-align: left; border-bottom-color: rgba(136, 136, 136, 1); white-space: nowrap; color: rgba(136, 136, 136, 1)">默认值</th><th style="margin: 0; padding: 10px 20px; -webkit-tap-highlight-color: transparent; text-align: left; border-bottom-color: rgba(136, 136, 136, 1); white-space: nowrap; color: rgba(136, 136, 136, 1)">必填</th><th style="margin: 0; padding: 10px 20px; -webkit-tap-highlight-color: transparent; text-align: left; border-bottom-color: rgba(136, 136, 136, 1); white-space: nowrap; color: rgba(136, 136, 136, 1)">说明</th><th style="margin: 0; padding: 10px 0 10px 20px; -webkit-tap-highlight-color: transparent; text-align: left; border-bottom-color: rgba(136, 136, 136, 1); white-space: nowrap; color: rgba(136, 136, 136, 1)">最低版本</th></tr>
</thead>
<tbody style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">scroll-x</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">boolean</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">false</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">允许横向滚动</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">1.0.0</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">scroll-y</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">boolean</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">false</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">允许纵向滚动</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">1.0.0</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">upper-threshold</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">number/string</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">50</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">距顶部/左边多远时,触发 scrolltoupper 事件</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">1.0.0</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">lower-threshold</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">number/string</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">50</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">距底部/右边多远时,触发 scrolltolower 事件</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">1.0.0</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">scroll-top</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">number/string</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">&nbsp;</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">设置竖向滚动条位置</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">1.0.0</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">scroll-left</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">number/string</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">&nbsp;</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">设置横向滚动条位置</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">1.0.0</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">scroll-into-view</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">string</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">&nbsp;</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">值应为某子元素id(id不能以数字开头)。设置哪个方向可滚动,则在哪个方向滚动到该元素</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">1.0.0</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">scroll-with-animation</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">boolean</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">false</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">在设置滚动条位置时使用动画过渡</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">1.0.0</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">enable-back-to-top</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">boolean</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">false</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">iOS点击顶部状态栏、安卓双击标题栏时,滚动条返回顶部,只支持竖向。自 2.27.3 版本开始,若非显式设置为 false,则在显示尺寸大于屏幕 90% 时自动开启。</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">1.0.0</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">enable-flex</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">boolean</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">false</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">启用 flexbox 布局。开启后,当前节点声明了 `display: flex` 就会成为 flex container,并作用于其孩子节点。</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">2.7.3</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">scroll-anchoring</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">boolean</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">false</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">开启 scroll anchoring 特性,即控制滚动位置不随内容变化而抖动,仅在 iOS 下生效,安卓下可参考 CSS `overflow-anchor` 属性。</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">2.8.2</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">enable-passive</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">boolean</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">false</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">开启 passive 特性,能优化一定的滚动性能</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">2.25.3</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">refresher-enabled</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">boolean</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">false</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">开启自定义下拉刷新</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">2.10.1</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">refresher-threshold</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">number</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">45</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">设置自定义下拉刷新阈值</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">2.10.1</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">refresher-default-style</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">string</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">"black"</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">设置自定义下拉刷新默认样式,支持设置 `black | white | none`, none 表示不使用默认样式</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">2.10.1</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">refresher-background</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">string</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">"#FFF"</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">设置自定义下拉刷新区域背景颜色</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">2.10.1</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">refresher-triggered</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">boolean</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">false</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">设置当前下拉刷新状态,true 表示下拉刷新已经被触发,false 表示下拉刷新未被触发</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">2.10.1</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">enhanced</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">boolean</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">false</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">启用 scroll-view 增强特性,启用后可通过&nbsp;ScrollViewContext&nbsp;操作 scroll-view</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">2.12.0</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">bounces</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">boolean</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">true</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">iOS 下 scroll-view 边界弹性控制 (同时开启 enhanced 属性后生效)</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">2.12.0</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">show-scrollbar</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">boolean</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">true</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">滚动条显隐控制 (同时开启 enhanced 属性后生效)</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">2.12.0</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">paging-enabled</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">boolean</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">false</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">分页滑动效果 (同时开启 enhanced 属性后生效)</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">2.12.0</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">fast-deceleration</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">boolean</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">false</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">滑动减速速率控制, 仅在 iOS 下生效 (同时开启 enhanced 属性后生效)</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">2.12.0</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">binddragstart</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">eventhandle</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">&nbsp;</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">滑动开始事件 (同时开启 enhanced 属性后生效) detail { scrollTop, scrollLeft }</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">2.12.0</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">binddragging</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">eventhandle</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">&nbsp;</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">滑动事件 (同时开启 enhanced 属性后生效) detail { scrollTop, scrollLeft }</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">2.12.0</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">binddragend</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">eventhandle</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">&nbsp;</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">滑动结束事件 (同时开启 enhanced 属性后生效) detail { scrollTop, scrollLeft, velocity }</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">2.12.0</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">bindscrolltoupper</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">eventhandle</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">&nbsp;</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">滚动到顶部/左边时触发</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">1.0.0</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">bindscrolltolower</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">eventhandle</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">&nbsp;</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">滚动到底部/右边时触发</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">1.0.0</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">bindscroll</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">eventhandle</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">&nbsp;</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">滚动时触发,event.detail = {scrollLeft, scrollTop, scrollHeight, scrollWidth, deltaX, deltaY}</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">1.0.0</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">bindrefresherpulling</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">eventhandle</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">&nbsp;</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">自定义下拉刷新控件被下拉</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">2.10.1</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">bindrefresherrefresh</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">eventhandle</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">&nbsp;</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">自定义下拉刷新被触发</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">2.10.1</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">bindrefresherrestore</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">eventhandle</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">&nbsp;</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">自定义下拉刷新被复位</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">2.10.1</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">bindrefresherabort</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">eventhandle</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">&nbsp;</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">自定义下拉刷新被中止</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">2.10.1</td>
</tr>
</tbody>
</table>
<p><span style="font-size: 14pt">wxml:</span></p>
<p>&nbsp;</p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 128, 0, 1)">&lt;!--</span><span style="color: rgba(0, 128, 0, 1)">pages/hello/index.wxml</span><span style="color: rgba(0, 128, 0, 1)">--&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">scroll-view </span><span style="color: rgba(255, 0, 0, 1)">class</span><span style="color: rgba(0, 0, 255, 1)">="box"</span><span style="color: rgba(255, 0, 0, 1)"> scroll-x</span><span style="color: rgba(0, 0, 255, 1)">="true"</span><span style="color: rgba(255, 0, 0, 1)"> scroll-y</span><span style="color: rgba(0, 0, 255, 1)">="true"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">view </span><span style="color: rgba(255, 0, 0, 1)">class</span><span style="color: rgba(0, 0, 255, 1)">="innerbox"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span><span style="color: rgba(0, 0, 0, 1)">
    内容内容内容内容内容内容内容内容内容内容内容内容内容
    内容内容内容内容内容内容内容内容内容内容内容内容内容
    内容内容内容内容内容内容内容内容内容内容内容内容内容
    内容内容内容内容内容内容内容内容内容内容内容内容内容
    内容内容内容内容内容内容内容内容内容内容内容内容内容
    内容内容内容内容内容内容内容内容内容内容内容内容内容
    内容内容内容内容内容内容内容内容内容内容内容内容内容
    内容内容内容内容内容内容内容内容内容内容内容内容内容
    内容内容内容内容内容内容内容内容内容内容内容内容内容
    内容内容内容内容内容内容内容内容内容内容内容内容内容
    内容内容内容内容内容内容内容内容内容内容内容内容内容
    内容内容内容内容内容内容内容内容内容内容内容内容内容
    内容内容内容内容内容内容内容内容内容内容内容内容内容
</span><span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">scroll-view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span></pre>
</div>
<p>wxcss:</p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 0, 1)">.innerbox{
width: 500px;
height: 100px;
background-color: lightblue;
}</span></pre>
</div>
<p>结果:</p>
<p><img src="https://img2023.cnblogs.com/blog/63651/202304/63651-20230418141328649-2028582448.png" alt="" loading="lazy"></p>
<h2>2.3、swiper与swiper-item</h2>
<p><span style="font-size: 15px">滑块视图容器。其中只可放置swiper-item组件</span></p>
</div>
<p><span style="font-size: 15px">通俗点讲呢,就是轮播图组件,微信小程序中,轮播图我们不用在自己去写</span></p>
<p><span style="font-size: 15px">可以用它自带的swiper组件与swiper-view共同来完成</span></p>
<p><span style="font-size: 15px"><strong>swiper属性说明:</strong></span></p>
<div class="table-wrp webview-table" style="margin: 1em 0 3em; padding: 0; -webkit-tap-highlight-color: transparent; overflow-x: auto; max-width: 100%; color: rgba(34, 34, 34, 1); font-family: -apple-system, BlinkMacSystemFont, &quot;SF UI Text&quot;, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif">
<table class="have-children-table" style="color: rgba(34, 34, 34, 1); font-family: -apple-system, BlinkMacSystemFont, &quot;SF UI Text&quot;, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif; margin-right: 0; margin-left: 0; padding: 0; -webkit-tap-highlight-color: transparent; width: 720px; border-spacing: 0; overflow: auto; font-size: 14px">
<thead style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent"><th style="margin: 0; padding: 10px 20px 10px 0; -webkit-tap-highlight-color: transparent; text-align: left; border-bottom-color: rgba(136, 136, 136, 1); white-space: nowrap; color: rgba(136, 136, 136, 1)">属性</th><th style="margin: 0; padding: 10px 20px; -webkit-tap-highlight-color: transparent; text-align: left; border-bottom-color: rgba(136, 136, 136, 1); white-space: nowrap; color: rgba(136, 136, 136, 1)">类型</th><th style="margin: 0; padding: 10px 20px; -webkit-tap-highlight-color: transparent; text-align: left; border-bottom-color: rgba(136, 136, 136, 1); white-space: nowrap; color: rgba(136, 136, 136, 1)">默认值</th><th style="margin: 0; padding: 10px 20px; -webkit-tap-highlight-color: transparent; text-align: left; border-bottom-color: rgba(136, 136, 136, 1); white-space: nowrap; color: rgba(136, 136, 136, 1)">必填</th><th style="margin: 0; padding: 10px 20px; -webkit-tap-highlight-color: transparent; text-align: left; border-bottom-color: rgba(136, 136, 136, 1); white-space: nowrap; color: rgba(136, 136, 136, 1)">说明</th><th style="margin: 0; padding: 10px 0 10px 20px; -webkit-tap-highlight-color: transparent; text-align: left; border-bottom-color: rgba(136, 136, 136, 1); white-space: nowrap; color: rgba(136, 136, 136, 1)">最低版本</th></tr>
</thead>
<tbody style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">indicator-dots</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">boolean</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">false</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">是否显示面板指示点</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">1.0.0</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">indicator-color</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">color</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">rgba(0, 0, 0, .3)</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">指示点颜色</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">1.1.0</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">indicator-active-color</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">color</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">#000000</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">当前选中的指示点颜色</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">1.1.0</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">autoplay</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">boolean</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">false</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">是否自动切换</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">1.0.0</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">current</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">number</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">0</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">当前所在滑块的 index</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">1.0.0</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">interval</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">number</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">5000</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">自动切换时间间隔</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">1.0.0</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">duration</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">number</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">500</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">滑动动画时长</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">1.0.0</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">circular</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">boolean</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">false</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">是否采用衔接滑动</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">1.0.0</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">vertical</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">boolean</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">false</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">滑动方向是否为纵向</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">1.0.0</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">previous-margin</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">string</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">"0px"</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">前边距,可用于露出前一项的一小部分,接受 px 和 rpx 值</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">1.9.0</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">next-margin</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">string</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">"0px"</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">后边距,可用于露出后一项的一小部分,接受 px 和 rpx 值</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">1.9.0</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">snap-to-edge</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">boolean</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">false</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">当 swiper-item 的个数大于等于 2,关闭 circular 并且开启 previous-margin 或 next-margin 的时候,可以指定这个边距是否应用到第一个、最后一个元素</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">2.12.1</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">display-multiple-items</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">number</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">1</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">同时显示的滑块数量</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">1.9.0</td>
</tr>
<tr class="have-children-tr" style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">easing-function</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">string</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">"default"</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">指定 swiper 切换缓动动画类型</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">2.6.5</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">bindchange</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">eventhandle</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">&nbsp;</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">current 改变时会触发 change 事件,event.detail = {current, source}</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">1.0.0</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">bindtransition</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">eventhandle</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">&nbsp;</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">swiper-item 的位置发生改变时会触发 transition 事件,event.detail = {dx: dx, dy: dy}</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">2.4.3</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">bindanimationfinish</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">eventhandle</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">&nbsp;</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">动画结束时会触发 animationfinish 事件,event.detail 同上</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">1.9.0</td>
</tr>
</tbody>
</table>
<p style="color: rgba(34, 34, 34, 1); font-family: -apple-system, BlinkMacSystemFont, &quot;SF UI Text&quot;, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif"><span style="font-size: 15px"><strong>swiper-item属性说明:</strong></span></p>
<div class="table-wrp" style="margin: 1em 0 3em; padding: 0; -webkit-tap-highlight-color: transparent; overflow-x: auto; max-width: 100%">
<table style="color: rgba(34, 34, 34, 1); font-family: -apple-system, BlinkMacSystemFont, &quot;SF UI Text&quot;, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif; margin-right: 0; margin-left: 0; padding: 0; -webkit-tap-highlight-color: transparent; width: 720px; border-spacing: 0; overflow: auto; font-size: 14px">
<thead style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent"><th style="margin: 0; padding: 10px 20px 10px 0; -webkit-tap-highlight-color: transparent; text-align: left; border-bottom-color: rgba(136, 136, 136, 1); white-space: nowrap; color: rgba(136, 136, 136, 1)">属性</th><th style="margin: 0; padding: 10px 20px; -webkit-tap-highlight-color: transparent; text-align: left; border-bottom-color: rgba(136, 136, 136, 1); white-space: nowrap; color: rgba(136, 136, 136, 1)">类型</th><th style="margin: 0; padding: 10px 20px; -webkit-tap-highlight-color: transparent; text-align: left; border-bottom-color: rgba(136, 136, 136, 1); white-space: nowrap; color: rgba(136, 136, 136, 1)">默认值</th><th style="margin: 0; padding: 10px 20px; -webkit-tap-highlight-color: transparent; text-align: left; border-bottom-color: rgba(136, 136, 136, 1); white-space: nowrap; color: rgba(136, 136, 136, 1)">必填</th><th style="margin: 0; padding: 10px 20px; -webkit-tap-highlight-color: transparent; text-align: left; border-bottom-color: rgba(136, 136, 136, 1); white-space: nowrap; color: rgba(136, 136, 136, 1)">说明</th><th style="margin: 0; padding: 10px 0 10px 20px; -webkit-tap-highlight-color: transparent; text-align: left; border-bottom-color: rgba(136, 136, 136, 1); white-space: nowrap; color: rgba(136, 136, 136, 1)">最低版本</th></tr>
</thead>
<tbody style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">item-id</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">string</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">&nbsp;</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">该 swiper-item 的标识符</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">1.9.0</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">skip-hidden-item-layout</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">boolean</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">false</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">是否跳过未显示的滑块布局,设为 true 可优化复杂情况下的滑动性能,但会丢失隐藏状态滑块的布局信息</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">1.9.0</td>
</tr>
</tbody>
</table>
<p style="color: rgba(34, 34, 34, 1); font-family: -apple-system, BlinkMacSystemFont, &quot;SF UI Text&quot;, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif"><img src="https://img2023.cnblogs.com/blog/2401301/202301/2401301-20230102162932000-2080447218.png" alt="" loading="lazy"></p>
<p style="color: rgba(34, 34, 34, 1); font-family: -apple-system, BlinkMacSystemFont, &quot;SF UI Text&quot;, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif">wxml</p>
<div class="cnblogs_code" style="color: rgba(34, 34, 34, 1); font-family: -apple-system, BlinkMacSystemFont, &quot;SF UI Text&quot;, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif">
<pre><span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">swiper </span><span style="color: rgba(255, 0, 0, 1)">class</span><span style="color: rgba(0, 0, 255, 1)">="swiper-content"</span><span style="color: rgba(255, 0, 0, 1)"> indicator-dots indicator-color</span><span style="color: rgba(0, 0, 255, 1)">="white"</span><span style="color: rgba(255, 0, 0, 1)"> indicator-active-color</span><span style="color: rgba(0, 0, 255, 1)">="gray"</span><span style="color: rgba(255, 0, 0, 1)"> autoplay</span><span style="color: rgba(0, 0, 255, 1)">="true"</span><span style="color: rgba(255, 0, 0, 1)"> interval</span><span style="color: rgba(0, 0, 255, 1)">="2000"</span><span style="color: rgba(255, 0, 0, 1)">
circular</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 128, 0, 1)">&lt;!--</span><span style="color: rgba(0, 128, 0, 1)"> circular:衔接滑动 </span><span style="color: rgba(0, 128, 0, 1)">--&gt;</span>
<span style="color: rgba(0, 128, 0, 1)">&lt;!--</span><span style="color: rgba(0, 128, 0, 1)"> 未激活的小圆点的颜色:indicator-color </span><span style="color: rgba(0, 128, 0, 1)">--&gt;</span>
<span style="color: rgba(0, 128, 0, 1)">&lt;!--</span><span style="color: rgba(0, 128, 0, 1)"> autoplay:自动轮播 </span><span style="color: rgba(0, 128, 0, 1)">--&gt;</span>
<span style="color: rgba(0, 128, 0, 1)">&lt;!--</span><span style="color: rgba(0, 128, 0, 1)"> indicator-dots:开启小圆点 </span><span style="color: rgba(0, 128, 0, 1)">--&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">swiper-item</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">view </span><span style="color: rgba(255, 0, 0, 1)">class</span><span style="color: rgba(0, 0, 255, 1)">="item"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>A<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">swiper-item</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">swiper-item</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">view </span><span style="color: rgba(255, 0, 0, 1)">class</span><span style="color: rgba(0, 0, 255, 1)">="item"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>B<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">swiper-item</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">swiper-item</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">view </span><span style="color: rgba(255, 0, 0, 1)">class</span><span style="color: rgba(0, 0, 255, 1)">="item"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>C<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">swiper-item</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">swiper</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span></pre>
</div>
<p style="color: rgba(34, 34, 34, 1); font-family: -apple-system, BlinkMacSystemFont, &quot;SF UI Text&quot;, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif">wxss</p>
<div class="cnblogs_code" style="color: rgba(34, 34, 34, 1); font-family: -apple-system, BlinkMacSystemFont, &quot;SF UI Text&quot;, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif">
<pre><span style="color: rgba(0, 0, 0, 1)">.swiper-content{
height: 150px;
}
.item{
height: 100%;
line-height: 150px;
text-align: center;
}
swiper-item:nth-child(1) .item{
background-color: green;
}
swiper-item:nth-child(2) .item{
background-color: yellow;
}
swiper-item:nth-child(3) .item{
background-color: pink;
}</span></pre>
</div>
<p><span style="font-size: 18.6667px">示例:</span></p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">swiper </span><span style="color: rgba(255, 0, 0, 1)">class</span><span style="color: rgba(0, 0, 255, 1)">="swiperContainer"</span><span style="color: rgba(255, 0, 0, 1)"> autoplay</span><span style="color: rgba(0, 0, 255, 1)">="true"</span><span style="color: rgba(255, 0, 0, 1)"> circular</span><span style="color: rgba(0, 0, 255, 1)">="true"</span><span style="color: rgba(255, 0, 0, 1)"> indicator-dots</span><span style="color: rgba(0, 0, 255, 1)">="true"</span><span style="color: rgba(255, 0, 0, 1)"> indicator-color</span><span style="color: rgba(0, 0, 255, 1)">="red"</span><span style="color: rgba(255, 0, 0, 1)"> indicator-active-color</span><span style="color: rgba(0, 0, 255, 1)">="white"</span><span style="color: rgba(255, 0, 0, 1)"> interval</span><span style="color: rgba(0, 0, 255, 1)">="500"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">swiper-item </span><span style="color: rgba(255, 0, 0, 1)">class</span><span style="color: rgba(0, 0, 255, 1)">="item a"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
    <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>Tom<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">swiper-item</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">swiper-item </span><span style="color: rgba(255, 0, 0, 1)">class</span><span style="color: rgba(0, 0, 255, 1)">="item b"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
    <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>Jack<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">swiper-item</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">swiper-item </span><span style="color: rgba(255, 0, 0, 1)">class</span><span style="color: rgba(0, 0, 255, 1)">="item c"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
    <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>Rose<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">swiper-item</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">swiper</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span></pre>
</div>
<div class="cnblogs_code">
<pre><span style="color: rgba(128, 0, 0, 1)">.item</span>{<span style="color: rgba(255, 0, 0, 1)">
font-size</span>:<span style="color: rgba(0, 0, 255, 1)"> 100rpx</span>;<span style="color: rgba(255, 0, 0, 1)">
height</span>:<span style="color: rgba(0, 0, 255, 1)"> 300rpx</span>;<span style="color: rgba(255, 0, 0, 1)">
text-align</span>:<span style="color: rgba(0, 0, 255, 1)"> center</span>;<span style="color: rgba(255, 0, 0, 1)">
line-height</span>:<span style="color: rgba(0, 0, 255, 1)"> 300rpx</span>;
}<span style="color: rgba(128, 0, 0, 1)">

.a</span>{<span style="color: rgba(255, 0, 0, 1)">
background</span>:<span style="color: rgba(0, 0, 255, 1)"> lightgreen</span>;
}<span style="color: rgba(128, 0, 0, 1)">
.b</span>{<span style="color: rgba(255, 0, 0, 1)">
background</span>:<span style="color: rgba(0, 0, 255, 1)"> lightblue</span>;<span style="color: rgba(255, 0, 0, 1)">
color</span>:<span style="color: rgba(0, 0, 255, 1)"> red</span>;
}<span style="color: rgba(128, 0, 0, 1)">
.c</span>{<span style="color: rgba(255, 0, 0, 1)">
background</span>:<span style="color: rgba(0, 0, 255, 1)"> lightcoral</span>;
}</pre>
</div>
<p><span style="font-size: 18.6667px">结果:</span></p>
<p><img src="https://img2023.cnblogs.com/blog/63651/202304/63651-20230420093500426-1069963699.png" alt="" loading="lazy"></p>
<h2 style="color: rgba(34, 34, 34, 1); font-family: -apple-system, BlinkMacSystemFont, &quot;SF UI Text&quot;, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif"><strong style="color: rgba(0, 0, 0, 1); font-family: &quot;PingFang SC&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif"><span style="font-size: 14pt">2.4、text</span></strong></h2>
<p style="color: rgba(34, 34, 34, 1); font-family: -apple-system, BlinkMacSystemFont, &quot;SF UI Text&quot;, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif"><span style="font-size: 15px">文本组件,类似与html中的span标签,是一个行内元素</span></p>
<p style="color: rgba(34, 34, 34, 1); font-family: -apple-system, BlinkMacSystemFont, &quot;SF UI Text&quot;, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif"><strong><span style="font-size: 15px">属性说明:</span></strong></p>
<div class="table-wrp webview-table" style="margin: 1em 0 3em; padding: 0; -webkit-tap-highlight-color: transparent; overflow-x: auto; max-width: 100%">
<p><img src="https://img2023.cnblogs.com/blog/63651/202304/63651-20230418141850786-1282464063.png" alt="" loading="lazy"></p>
<p><img src="https://img2023.cnblogs.com/blog/2401301/202301/2401301-20230102163548097-484156111.png" alt="" loading="lazy"></p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">text</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>需求文档策划书<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">text</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span><span style="color: rgba(0, 128, 0, 1)">&lt;!--</span><span style="color: rgba(0, 128, 0, 1)"> 长按选中效果需加上selectable </span><span style="color: rgba(0, 128, 0, 1)">--&gt;</span></pre>
</div>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">text</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>1<span style="color: rgba(255, 0, 0, 1)">&amp;nbsp;</span>2 <span style="color: rgba(255, 0, 0, 1)">&amp;gt;</span> <span style="color: rgba(255, 0, 0, 1)">&amp;lt;</span><span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">text</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span></pre>
</div>
<p>示例:</p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">text </span><span style="color: rgba(255, 0, 0, 1)">user-select</span><span style="color: rgba(0, 0, 255, 1)">="true"</span><span style="color: rgba(255, 0, 0, 1)"> decode</span><span style="color: rgba(0, 0, 255, 1)">="true"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>Hello<span style="color: rgba(255, 0, 0, 1)">&amp;nbsp;&amp;nbsp;&amp;nbsp;</span>TEXT! <span style="color: rgba(255, 0, 0, 1)">&amp;lt;</span>
    <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">text</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span><span style="color: rgba(0, 0, 0, 1)">
      嵌套text
    </span><span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">text</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">text</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">text</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>1<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">text</span><span style="color: rgba(0, 0, 255, 1)">&gt;&lt;</span><span style="color: rgba(128, 0, 0, 1)">text</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>2<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">text</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span></pre>
</div>
<p>结果:</p>
<p><img src="https://img2023.cnblogs.com/blog/63651/202304/63651-20230420094323910-1124593569.png" alt="" width="365" height="636" loading="lazy"></p>
<p>原样输出,加上decode会编码。</p>
<ol>
<li><code>tip</code>: decode可以解析的有&nbsp;<code>&amp;nbsp;</code>&nbsp;<code>&amp;lt;</code>&nbsp;<code>&amp;gt;</code>&nbsp;<code>&amp;amp;</code>&nbsp;<code>&amp;apos;</code>&nbsp;<code>&amp;ensp;</code>&nbsp;<code>&amp;emsp;</code></li>
<li><code>tip</code>: 各个操作系统的空格标准并不一致。</li>
<li><code>tip</code>:text&nbsp;组件内只支持&nbsp;text&nbsp;嵌套。</li>
<li><code>tip</code>: 除了文本节点以外的其他节点都无法长按选中。</li>
<li><code>bug</code>: 基础库版本低于&nbsp;<code>2.1.0</code>&nbsp;时,&nbsp;text&nbsp;组件内嵌的&nbsp;text&nbsp;style 设置可能不会生效。</li>
</ol>
<p><strong><span style="font-size: 14pt">2.5、rich-text</span></strong></p>
</div>
<div class="table-wrp webview-table" style="margin: 1em 0 3em; padding: 0; -webkit-tap-highlight-color: transparent; overflow-x: auto; max-width: 100%">
<p><span style="font-size: 15px">富文本组件,支持把HTML字符串渲染为WXML结构</span></p>
<p><strong><span style="font-size: 15px">属性说明:</span></strong></p>
<div class="table-wrp" style="margin: 1em 0 3em; padding: 0; -webkit-tap-highlight-color: transparent; overflow-x: auto; max-width: 100%">
<table class="have-children-table" style="margin-right: 0; margin-left: 0; padding: 0; -webkit-tap-highlight-color: transparent; width: 720px; border-spacing: 0; overflow: auto; font-size: 14px">
<thead style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent"><th style="margin: 0; padding: 10px 20px 10px 0; -webkit-tap-highlight-color: transparent; text-align: left; border-bottom-color: rgba(136, 136, 136, 1); white-space: nowrap; color: rgba(136, 136, 136, 1)">&nbsp;</th><th style="margin: 0; padding: 10px 20px 10px 0; -webkit-tap-highlight-color: transparent; text-align: left; border-bottom-color: rgba(136, 136, 136, 1); white-space: nowrap; color: rgba(136, 136, 136, 1)">属性</th><th style="margin: 0; padding: 10px 20px; -webkit-tap-highlight-color: transparent; text-align: left; border-bottom-color: rgba(136, 136, 136, 1); white-space: nowrap; color: rgba(136, 136, 136, 1)">类型</th><th style="margin: 0; padding: 10px 20px; -webkit-tap-highlight-color: transparent; text-align: left; border-bottom-color: rgba(136, 136, 136, 1); white-space: nowrap; color: rgba(136, 136, 136, 1)">默认值</th><th style="margin: 0; padding: 10px 20px; -webkit-tap-highlight-color: transparent; text-align: left; border-bottom-color: rgba(136, 136, 136, 1); white-space: nowrap; color: rgba(136, 136, 136, 1)">必填</th><th style="margin: 0; padding: 10px 20px; -webkit-tap-highlight-color: transparent; text-align: left; border-bottom-color: rgba(136, 136, 136, 1); white-space: nowrap; color: rgba(136, 136, 136, 1)">说明</th><th style="margin: 0; padding: 10px 0 10px 20px; -webkit-tap-highlight-color: transparent; text-align: left; border-bottom-color: rgba(136, 136, 136, 1); white-space: nowrap; color: rgba(136, 136, 136, 1)">最低版本</th></tr>
</thead>
<tbody style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 13.6px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal; width: 10px">&nbsp;</td>
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">nodes</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">array/string</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">[]</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">节点列表/HTML String</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">1.4.0</td>
</tr>
<tr class="have-children-tr" style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 13.6px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal; width: 10px">&nbsp;</td>
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">space</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">string</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">&nbsp;</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">显示连续空格</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">2.4.1</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 13.6px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal; width: 10px">&nbsp;</td>
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">user-select</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">boolean</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">false</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">文本是否可选,该属性会使节点显示为 block</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">2.24.0</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p><img src="https://img2023.cnblogs.com/blog/2401301/202301/2401301-20230102163946246-348276354.png" alt="" loading="lazy"></p>
<p>&nbsp;</p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">rich-text </span><span style="color: rgba(255, 0, 0, 1)">nodes</span><span style="color: rgba(0, 0, 255, 1)">="&lt;h1 style='color: green;'&gt;标题一&lt;/h1&gt;"</span><span style="color: rgba(0, 0, 255, 1)">&gt;&lt;/</span><span style="color: rgba(128, 0, 0, 1)">rich-text</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span></pre>
</div>
<p>&nbsp;</p>
<ol>
<li><code>tip</code>: nodes 不推荐使用 String 类型,性能会有所下降。</li>
<li><code>tip</code>:&nbsp;<code>rich-text</code>&nbsp;组件内屏蔽所有节点的事件。</li>
<li><code>tip</code>: attrs 属性不支持 id ,支持 class 。</li>
<li><code>tip</code>: name 属性大小写不敏感。</li>
<li><code>tip</code>: 如果使用了不受信任的HTML节点,该节点及其所有子节点将会被移除。</li>
<li><code>tip</code>: img 标签仅支持网络图片。</li>
<li><code>tip</code>: 如果在自定义组件中使用&nbsp;<code>rich-text</code>&nbsp;组件,那么仅自定义组件的 wxss 样式对&nbsp;<code>rich-text</code>&nbsp;中的 class 生效</li>
</ol>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">text</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>{{"<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">hr</span><span style="color: rgba(0, 0, 255, 1)">/&gt;</span>"}}<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">text</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">rich-text </span><span style="color: rgba(255, 0, 0, 1)">nodes</span><span style="color: rgba(0, 0, 255, 1)">="{{'&lt;hr/&gt;'}}"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">rich-text</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>123<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">rich-text </span><span style="color: rgba(255, 0, 0, 1)">nodes</span><span style="color: rgba(0, 0, 255, 1)">="&lt;hr/&gt;"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">rich-text</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span></pre>
</div>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">text</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span><span style="color: rgba(0, 0, 0, 1)">
{{"原样输出:</span><span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">hr</span><span style="color: rgba(0, 0, 255, 1)">/&gt;</span><span style="color: rgba(0, 0, 0, 1)">"}}
</span><span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">text</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">rich-text </span><span style="color: rgba(255, 0, 0, 1)">nodes</span><span style="color: rgba(0, 0, 255, 1)">="解析成HTML:&lt;hr/&gt;"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">rich-text</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">rich-text </span><span style="color: rgba(255, 0, 0, 1)">nodes</span><span style="color: rgba(0, 0, 255, 1)">="{{mynodes}}"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">rich-text</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span></pre>
</div>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> pages/hello/index.js</span>
<span style="color: rgba(0, 0, 0, 1)">Page({

</span><span style="color: rgba(0, 128, 0, 1)">/*</span><span style="color: rgba(0, 128, 0, 1)">*
   * 页面的初始数据
   </span><span style="color: rgba(0, 128, 0, 1)">*/</span><span style="color: rgba(0, 0, 0, 1)">
data: {
    mynodes:[{
      name:</span>"div"<span style="color: rgba(0, 0, 0, 1)">,
      attrs:{
      class:</span>"blue"<span style="color: rgba(0, 0, 0, 1)">
      },
      children:[{
      type:</span>"text"<span style="color: rgba(0, 0, 0, 1)">,
      text:</span>"Hello Nodes!"<span style="color: rgba(0, 0, 0, 1)">
      }]
    }]
},

</span><span style="color: rgba(0, 128, 0, 1)">/*</span><span style="color: rgba(0, 128, 0, 1)">*
   * 生命周期函数--监听页面加载
   </span><span style="color: rgba(0, 128, 0, 1)">*/</span><span style="color: rgba(0, 0, 0, 1)">
onLoad(options) {

},

</span><span style="color: rgba(0, 128, 0, 1)">/*</span><span style="color: rgba(0, 128, 0, 1)">*
   * 生命周期函数--监听页面初次渲染完成
   </span><span style="color: rgba(0, 128, 0, 1)">*/</span><span style="color: rgba(0, 0, 0, 1)">
onReady() {

},

</span><span style="color: rgba(0, 128, 0, 1)">/*</span><span style="color: rgba(0, 128, 0, 1)">*
   * 生命周期函数--监听页面显示
   </span><span style="color: rgba(0, 128, 0, 1)">*/</span><span style="color: rgba(0, 0, 0, 1)">
onShow() {

},

</span><span style="color: rgba(0, 128, 0, 1)">/*</span><span style="color: rgba(0, 128, 0, 1)">*
   * 生命周期函数--监听页面隐藏
   </span><span style="color: rgba(0, 128, 0, 1)">*/</span><span style="color: rgba(0, 0, 0, 1)">
onHide() {

},

</span><span style="color: rgba(0, 128, 0, 1)">/*</span><span style="color: rgba(0, 128, 0, 1)">*
   * 生命周期函数--监听页面卸载
   </span><span style="color: rgba(0, 128, 0, 1)">*/</span><span style="color: rgba(0, 0, 0, 1)">
onUnload() {

},

</span><span style="color: rgba(0, 128, 0, 1)">/*</span><span style="color: rgba(0, 128, 0, 1)">*
   * 页面相关事件处理函数--监听用户下拉动作
   </span><span style="color: rgba(0, 128, 0, 1)">*/</span><span style="color: rgba(0, 0, 0, 1)">
onPullDownRefresh() {

},

</span><span style="color: rgba(0, 128, 0, 1)">/*</span><span style="color: rgba(0, 128, 0, 1)">*
   * 页面上拉触底事件的处理函数
   </span><span style="color: rgba(0, 128, 0, 1)">*/</span><span style="color: rgba(0, 0, 0, 1)">
onReachBottom() {

},

</span><span style="color: rgba(0, 128, 0, 1)">/*</span><span style="color: rgba(0, 128, 0, 1)">*
   * 用户点击右上角分享
   </span><span style="color: rgba(0, 128, 0, 1)">*/</span><span style="color: rgba(0, 0, 0, 1)">
onShareAppMessage() {

}
})</span></pre>
</div>
<div class="cnblogs_code">
<pre><span style="color: rgba(128, 0, 0, 1)">.blue</span>{<span style="color: rgba(255, 0, 0, 1)">
color</span>:<span style="color: rgba(0, 0, 255, 1)">blue
</span>}</pre>
</div>
<p>结果:</p>
<p><img src="https://img2023.cnblogs.com/blog/63651/202304/63651-20230420100044889-1794099038.png" alt="" loading="lazy"></p>
<h2><strong><span style="font-size: 14pt">2.6、button</span></strong></h2>
<p><span style="font-size: 15px">按钮组件</span></p>
<p><span style="font-size: 15px">相对于html的button,更加丰富,可以通过属性type来改变按钮的不同样式</span></p>
<p><span style="font-size: 15px">微信小程序的button按钮可以调用很多功能(</span><span style="font-size: 15px">通过open-type可以调用客服,转发,获取用户信息,获取用户授权等</span><span style="font-size: 15px">)</span></p>
<p><strong><span style="font-size: 15px">属性说明:</span></strong></p>
<p>&nbsp;</p>
<p><img src="https://img2023.cnblogs.com/blog/63651/202304/63651-20230418144906717-1212299554.png" alt="" loading="lazy"></p>
<div class="table-wrp webview-table" style="margin: 1em 0 3em; padding: 0; -webkit-tap-highlight-color: transparent; overflow-x: auto; max-width: 100%">
<table class="have-children-table" style="margin-right: 0; margin-left: 0; padding: 0; -webkit-tap-highlight-color: transparent; width: 751.7px; border-spacing: 0; overflow: auto; font-size: 14px">
<thead style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent"><th style="margin: 0; padding: 10px 20px 10px 0; -webkit-tap-highlight-color: transparent; text-align: left; border-bottom-color: rgba(136, 136, 136, 1); white-space: nowrap; color: rgba(136, 136, 136, 1)">属性</th><th style="margin: 0; padding: 10px 20px; -webkit-tap-highlight-color: transparent; text-align: left; border-bottom-color: rgba(136, 136, 136, 1); white-space: nowrap; color: rgba(136, 136, 136, 1)">类型</th><th style="margin: 0; padding: 10px 20px; -webkit-tap-highlight-color: transparent; text-align: left; border-bottom-color: rgba(136, 136, 136, 1); white-space: nowrap; color: rgba(136, 136, 136, 1)">默认值</th><th style="margin: 0; padding: 10px 20px; -webkit-tap-highlight-color: transparent; text-align: left; border-bottom-color: rgba(136, 136, 136, 1); white-space: nowrap; color: rgba(136, 136, 136, 1)">必填</th><th style="margin: 0; padding: 10px 20px; -webkit-tap-highlight-color: transparent; text-align: left; border-bottom-color: rgba(136, 136, 136, 1); white-space: nowrap; color: rgba(136, 136, 136, 1)">说明</th><th style="margin: 0; padding: 10px 0 10px 20px; -webkit-tap-highlight-color: transparent; text-align: left; border-bottom-color: rgba(136, 136, 136, 1); white-space: nowrap; color: rgba(136, 136, 136, 1)">最低版本</th></tr>
</thead>
<tbody style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<tr class="have-children-tr" style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">size</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">string</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">default</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">按钮的大小</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">1.0.0</td>
</tr>
<tr class="have-children-tr" style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">type</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">string</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">default</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">按钮的样式类型</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">1.0.0</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">plain</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">boolean</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">false</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">按钮是否镂空,背景色透明</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">1.0.0</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">disabled</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">boolean</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">false</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">是否禁用</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">1.0.0</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">loading</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">boolean</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">false</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">名称前是否带 loading 图标</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">1.0.0</td>
</tr>
<tr class="have-children-tr" style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">form-type</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">string</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">&nbsp;</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">用于&nbsp;form&nbsp;组件,点击分别会触发&nbsp;form&nbsp;组件的 submit/reset 事件</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">1.0.0</td>
</tr>
<tr class="have-children-tr" style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">open-type</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">string</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">&nbsp;</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">微信开放能力</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">1.1.0</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">hover-class</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">string</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">button-hover</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">指定按钮按下去的样式类。当 `hover-class="none"` 时,没有点击态效果</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">1.0.0</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">hover-stop-propagation</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">boolean</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">false</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">指定是否阻止本节点的祖先节点出现点击态</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">1.5.0</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">hover-start-time</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">number</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">20</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">按住后多久出现点击态,单位毫秒</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">1.0.0</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">hover-stay-time</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">number</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">70</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">手指松开后点击态保留时间,单位毫秒</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">1.0.0</td>
</tr>
<tr class="have-children-tr" style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">lang</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">string</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">en</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">指定返回用户信息的语言,zh_CN 简体中文,zh_TW 繁体中文,en 英文。</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">1.3.0</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">session-from</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">string</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">&nbsp;</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">会话来源,open-type="contact"时有效</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">1.4.0</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">send-message-title</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">string</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">当前标题</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">会话内消息卡片标题,open-type="contact"时有效</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">1.5.0</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">send-message-path</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">string</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">当前分享路径</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">会话内消息卡片点击跳转小程序路径,open-type="contact"时有效</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">1.5.0</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">send-message-img</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">string</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">截图</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">会话内消息卡片图片,open-type="contact"时有效</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">1.5.0</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">app-parameter</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">string</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">&nbsp;</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">打开 APP 时,向 APP 传递的参数,open-type=launchApp时有效</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">1.9.5</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">show-message-card</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">boolean</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">false</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">是否显示会话内消息卡片,设置此参数为 true,用户进入客服会话会在右下角显示"可能要发送的小程序"提示,用户点击后可以快速发送小程序消息,open-type="contact"时有效</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">1.5.0</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">bindgetuserinfo</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">eventhandle</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">&nbsp;</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">用户点击该按钮时,会返回获取到的用户信息,回调的 detail 数据与wx.getUserInfo返回的一致,open-type="getUserInfo"时有效</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">1.3.0</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">bindcontact</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">eventhandle</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">&nbsp;</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">客服消息回调,open-type="contact"时有效</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">1.5.0</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">bindgetphonenumber</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">eventhandle</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">&nbsp;</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">获取用户手机号回调,open-type=getPhoneNumber时有效</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">1.2.0</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">binderror</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">eventhandle</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">&nbsp;</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">当使用开放能力时,发生错误的回调,open-type=launchApp时有效</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">1.9.5</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">bindopensetting</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">eventhandle</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">&nbsp;</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">在打开授权设置页后回调,open-type=openSetting时有效</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">2.0.7</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">bindlaunchapp</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">eventhandle</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">&nbsp;</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">打开 APP 成功的回调,open-type=launchApp时有效</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">2.4.4</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">bindchooseavatar</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">eventhandle</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">&nbsp;</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">获取用户头像回调,open-type=chooseAvatar时有效</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">2.21.2</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p><img src="https://img2023.cnblogs.com/blog/2401301/202301/2401301-20230102164747362-509396905.png" alt="" loading="lazy"></p>
<p>&nbsp;</p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">button</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>普通按钮<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">button</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">button </span><span style="color: rgba(255, 0, 0, 1)">type</span><span style="color: rgba(0, 0, 255, 1)">="primary"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>主色调按钮<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">button</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">button </span><span style="color: rgba(255, 0, 0, 1)">type</span><span style="color: rgba(0, 0, 255, 1)">="warn"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>警告按钮<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">button</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>

<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">button </span><span style="color: rgba(255, 0, 0, 1)">size</span><span style="color: rgba(0, 0, 255, 1)">="mini"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>普通按钮<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">button</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">button </span><span style="color: rgba(255, 0, 0, 1)">type</span><span style="color: rgba(0, 0, 255, 1)">="primary"</span><span style="color: rgba(255, 0, 0, 1)"> size</span><span style="color: rgba(0, 0, 255, 1)">="mini"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>主色调按钮<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">button</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">button </span><span style="color: rgba(255, 0, 0, 1)">type</span><span style="color: rgba(0, 0, 255, 1)">="warn"</span><span style="color: rgba(255, 0, 0, 1)"> size</span><span style="color: rgba(0, 0, 255, 1)">="mini"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>警告按钮<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">button</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span></pre>
</div>
<table class="have-children-table">
<tbody>
<tr class="have-children-tr show-children">
<td>open-type</td>
<td>string</td>
<td>&nbsp;</td>
<td>否</td>
<td>微信开放能力</td>
<td>1.1.0</td>
</tr>
<tr class="children-table">
<td>&nbsp;</td>
<td colspan="6">
<table>
<thead>
<tr><th>合法值</th><th>说明</th><th>最低版本</th></tr>
</thead>
<tbody>
<tr>
<td>contact</td>
<td>打开客服会话,如果用户在会话中点击消息卡片后返回小程序,可以从 bindcontact 回调中获得具体信息,具体说明&nbsp;(*小程序插件中不能使用*)</td>
<td>1.1.0</td>
</tr>
<tr>
<td>share</td>
<td>触发用户转发,使用前建议先阅读使用指引</td>
<td>1.2.0</td>
</tr>
<tr>
<td>getPhoneNumber</td>
<td>获取用户手机号,可以从bindgetphonenumber回调中获取到用户信息,具体说明&nbsp;(*小程序插件中不能使用*)</td>
<td>1.2.0</td>
</tr>
<tr>
<td>getUserInfo</td>
<td>获取用户信息,可以从bindgetuserinfo回调中获取到用户信息 (*小程序插件中不能使用*)</td>
<td>1.3.0</td>
</tr>
<tr>
<td>launchApp</td>
<td>打开APP,可以通过app-parameter属性设定向APP传的参数具体说明</td>
<td>1.9.5</td>
</tr>
<tr>
<td>openSetting</td>
<td>打开授权设置页</td>
<td>2.0.7</td>
</tr>
<tr>
<td>feedback</td>
<td>打开“意见反馈”页面,用户可提交反馈内容并上传日志,开发者可以登录小程序管理后台后进入左侧菜单“客服反馈”页面获取到反馈内容</td>
<td>2.1.0</td>
</tr>
<tr>
<td>chooseAvatar</td>
<td>获取用户头像,可以从bindchooseavatar回调中获取到头像信息</td>
<td>2.21.2</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">button </span><span style="color: rgba(255, 0, 0, 1)">type</span><span style="color: rgba(0, 0, 255, 1)">="default"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>默认<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">button</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">button </span><span style="color: rgba(255, 0, 0, 1)">type</span><span style="color: rgba(0, 0, 255, 1)">="primary"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>确定<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">button</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">button </span><span style="color: rgba(255, 0, 0, 1)">type</span><span style="color: rgba(0, 0, 255, 1)">="warn"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>警告<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">button</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>

<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">button </span><span style="color: rgba(255, 0, 0, 1)">type</span><span style="color: rgba(0, 0, 255, 1)">="primary"</span><span style="color: rgba(255, 0, 0, 1)"> size</span><span style="color: rgba(0, 0, 255, 1)">="mini"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>打印<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">button</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">button </span><span style="color: rgba(255, 0, 0, 1)">type</span><span style="color: rgba(0, 0, 255, 1)">="warn"</span><span style="color: rgba(255, 0, 0, 1)"> size</span><span style="color: rgba(0, 0, 255, 1)">="mini"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>删除<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">button</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>

<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">button </span><span style="color: rgba(255, 0, 0, 1)">type</span><span style="color: rgba(0, 0, 255, 1)">="primary"</span><span style="color: rgba(255, 0, 0, 1)"> plain</span><span style="color: rgba(0, 0, 255, 1)">="true"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>镂空<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">button</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">button </span><span style="color: rgba(255, 0, 0, 1)">type</span><span style="color: rgba(0, 0, 255, 1)">="primary"</span><span style="color: rgba(255, 0, 0, 1)"> loading</span><span style="color: rgba(0, 0, 255, 1)">="true"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>加载中<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">button</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">button </span><span style="color: rgba(255, 0, 0, 1)">open-type</span><span style="color: rgba(0, 0, 255, 1)">="chooseAvatar"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>获取头像<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">button</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span></pre>
</div>
<p>点击获取头像时的效果:</p>
<p><img src="https://img2023.cnblogs.com/blog/63651/202304/63651-20230420101050398-678300022.jpg" alt="" width="408" height="907" loading="lazy"></p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 0, 1)">data: {
      </span>"avatarUrl":"https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0"<span style="color: rgba(0, 0, 0, 1)">
    },
   
    onChooseavatar(e){
      let {avatarUrl}</span>=<span style="color: rgba(0, 0, 0, 1)">e.detail;
      </span><span style="color: rgba(0, 0, 255, 1)">this</span><span style="color: rgba(0, 0, 0, 1)">.setData({avatarUrl});
    },</span></pre>
</div>
<p>&nbsp;</p>
<h2><strong><span style="font-size: 14pt">2.7、image</span></strong></h2>
<p style="margin: 0 0 0.5em; padding: 0; -webkit-tap-highlight-color: transparent"><span style="font-size: 15px">图片组件。支持 JPG、PNG、SVG、WEBP、GIF 等格式</span></p>
<p style="margin: 0 0 0.5em; padding: 0; -webkit-tap-highlight-color: transparent"><span style="font-size: 15px">相比与html的image,可以通过mode属性更加灵活的改变图片样式</span></p>
<p style="margin: 0 0 0.5em; padding: 0; -webkit-tap-highlight-color: transparent"><strong>属性说明</strong></p>
<div class="table-wrp webview-table" style="margin: 1em 0 3em; padding: 0; -webkit-tap-highlight-color: transparent; overflow-x: auto; max-width: 100%">
<table class="have-children-table" style="margin-right: 0; margin-left: 0; padding: 0; -webkit-tap-highlight-color: transparent; width: 720px; border-spacing: 0; overflow: auto; font-size: 14px">
<thead style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent"><th style="margin: 0; padding: 10px 20px 10px 0; -webkit-tap-highlight-color: transparent; text-align: left; border-bottom-color: rgba(136, 136, 136, 1); white-space: nowrap; color: rgba(136, 136, 136, 1)">&nbsp;</th><th style="margin: 0; padding: 10px 20px 10px 0; -webkit-tap-highlight-color: transparent; text-align: left; border-bottom-color: rgba(136, 136, 136, 1); white-space: nowrap; color: rgba(136, 136, 136, 1)">属性</th><th style="margin: 0; padding: 10px 20px; -webkit-tap-highlight-color: transparent; text-align: left; border-bottom-color: rgba(136, 136, 136, 1); white-space: nowrap; color: rgba(136, 136, 136, 1)">类型</th><th style="margin: 0; padding: 10px 20px; -webkit-tap-highlight-color: transparent; text-align: left; border-bottom-color: rgba(136, 136, 136, 1); white-space: nowrap; color: rgba(136, 136, 136, 1)">默认值</th><th style="margin: 0; padding: 10px 20px; -webkit-tap-highlight-color: transparent; text-align: left; border-bottom-color: rgba(136, 136, 136, 1); white-space: nowrap; color: rgba(136, 136, 136, 1)">必填</th><th style="margin: 0; padding: 10px 20px; -webkit-tap-highlight-color: transparent; text-align: left; border-bottom-color: rgba(136, 136, 136, 1); white-space: nowrap; color: rgba(136, 136, 136, 1)">说明</th><th style="margin: 0; padding: 10px 0 10px 20px; -webkit-tap-highlight-color: transparent; text-align: left; border-bottom-color: rgba(136, 136, 136, 1); white-space: nowrap; color: rgba(136, 136, 136, 1)">最低版本</th></tr>
</thead>
<tbody style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 13.6px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal; width: 10px">&nbsp;</td>
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">src</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">string</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">&nbsp;</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">图片资源地址</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">1.0.0</td>
</tr>
<tr class="have-children-tr show-children" style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 13.6px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom: none; height: 62px; box-sizing: border-box; word-break: normal; width: 10px">&nbsp;</td>
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom: none; height: 62px; box-sizing: border-box; word-break: normal">mode</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom: none; height: 62px; box-sizing: border-box; word-break: normal">string</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom: none; height: 62px; box-sizing: border-box; word-break: normal">scaleToFill</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom: none; height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom: none; height: 62px; box-sizing: border-box; word-break: normal">图片裁剪、缩放的模式</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom: none; height: 62px; box-sizing: border-box; word-break: normal">1.0.0</td>
</tr>
<tr class="children-table" style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 10px 13.6px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal; width: 10px">&nbsp;</td>
<td style="margin: 0; padding: 10px 0 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal" colspan="6">
<table style="margin-right: 0; margin-left: 0; padding: 0; -webkit-tap-highlight-color: transparent; width: 694.4px; border-spacing: 0; overflow: auto; font-size: 14px">
<thead style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; background-color: rgba(248, 248, 248, 1)">
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent"><th style="margin: 0; padding: 10px 20px 10px 16px; -webkit-tap-highlight-color: transparent; font-weight: 400; text-align: left; border-bottom: none; white-space: nowrap; opacity: 0.5; border-top-left-radius: 8px; width: 102.875px">合法值</th><th style="margin: 0; padding: 10px 20px 10px 0; -webkit-tap-highlight-color: transparent; font-weight: 400; text-align: left; border-bottom: none; white-space: nowrap; opacity: 0.5">说明</th><th style="margin: 0; padding: 10px 0 10px 20px; -webkit-tap-highlight-color: transparent; font-weight: 400; text-align: left; border-bottom: none; white-space: nowrap; opacity: 0.5; border-top-right-radius: 8px; width: 118.875px">最低版本</th></tr>
</thead>
<tbody style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; background-color: rgba(251, 251, 251, 1)">
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 13.6px 20px 16px; -webkit-tap-highlight-color: transparent; border-bottom: none; height: 62px; box-sizing: border-box; word-break: normal; width: 10px; border-top-color: rgba(0, 0, 0, 0.05); opacity: 0.9">scaleToFill</td>
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; border-bottom: none; height: 62px; box-sizing: border-box; word-break: normal; border-top-color: rgba(0, 0, 0, 0.05); opacity: 0.9">缩放模式,不保持纵横比缩放图片,使图片的宽高完全拉伸至填满 image 元素</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; border-bottom: none; height: 62px; box-sizing: border-box; word-break: normal; border-top-color: rgba(0, 0, 0, 0.05); opacity: 0.9">&nbsp;</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 13.6px 20px 16px; -webkit-tap-highlight-color: transparent; border-bottom: none; height: 62px; box-sizing: border-box; word-break: normal; width: 10px; border-top-color: rgba(0, 0, 0, 0.05); opacity: 0.9">aspectFit</td>
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; border-bottom: none; height: 62px; box-sizing: border-box; word-break: normal; border-top-color: rgba(0, 0, 0, 0.05); opacity: 0.9">缩放模式,保持纵横比缩放图片,使图片的长边能完全显示出来。也就是说,可以完整地将图片显示出来。</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; border-bottom: none; height: 62px; box-sizing: border-box; word-break: normal; border-top-color: rgba(0, 0, 0, 0.05); opacity: 0.9">&nbsp;</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 13.6px 20px 16px; -webkit-tap-highlight-color: transparent; border-bottom: none; height: 62px; box-sizing: border-box; word-break: normal; width: 10px; border-top-color: rgba(0, 0, 0, 0.05); opacity: 0.9">aspectFill</td>
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; border-bottom: none; height: 62px; box-sizing: border-box; word-break: normal; border-top-color: rgba(0, 0, 0, 0.05); opacity: 0.9">缩放模式,保持纵横比缩放图片,只保证图片的短边能完全显示出来。也就是说,图片通常只在水平或垂直方向是完整的,另一个方向将会发生截取。</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; border-bottom: none; height: 62px; box-sizing: border-box; word-break: normal; border-top-color: rgba(0, 0, 0, 0.05); opacity: 0.9">&nbsp;</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 13.6px 20px 16px; -webkit-tap-highlight-color: transparent; border-bottom: none; height: 62px; box-sizing: border-box; word-break: normal; width: 10px; border-top-color: rgba(0, 0, 0, 0.05); opacity: 0.9">widthFix</td>
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; border-bottom: none; height: 62px; box-sizing: border-box; word-break: normal; border-top-color: rgba(0, 0, 0, 0.05); opacity: 0.9">缩放模式,宽度不变,高度自动变化,保持原图宽高比不变</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; border-bottom: none; height: 62px; box-sizing: border-box; word-break: normal; border-top-color: rgba(0, 0, 0, 0.05); opacity: 0.9">&nbsp;</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 13.6px 20px 16px; -webkit-tap-highlight-color: transparent; border-bottom: none; height: 62px; box-sizing: border-box; word-break: normal; width: 10px; border-top-color: rgba(0, 0, 0, 0.05); opacity: 0.9">heightFix</td>
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; border-bottom: none; height: 62px; box-sizing: border-box; word-break: normal; border-top-color: rgba(0, 0, 0, 0.05); opacity: 0.9">缩放模式,高度不变,宽度自动变化,保持原图宽高比不变</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; border-bottom: none; height: 62px; box-sizing: border-box; word-break: normal; border-top-color: rgba(0, 0, 0, 0.05); opacity: 0.9">2.10.3</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 13.6px 20px 16px; -webkit-tap-highlight-color: transparent; border-bottom: none; height: 62px; box-sizing: border-box; word-break: normal; width: 10px; border-top-color: rgba(0, 0, 0, 0.05); opacity: 0.9">top</td>
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; border-bottom: none; height: 62px; box-sizing: border-box; word-break: normal; border-top-color: rgba(0, 0, 0, 0.05); opacity: 0.9">裁剪模式,不缩放图片,只显示图片的顶部区域</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; border-bottom: none; height: 62px; box-sizing: border-box; word-break: normal; border-top-color: rgba(0, 0, 0, 0.05); opacity: 0.9">&nbsp;</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 13.6px 20px 16px; -webkit-tap-highlight-color: transparent; border-bottom: none; height: 62px; box-sizing: border-box; word-break: normal; width: 10px; border-top-color: rgba(0, 0, 0, 0.05); opacity: 0.9">bottom</td>
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; border-bottom: none; height: 62px; box-sizing: border-box; word-break: normal; border-top-color: rgba(0, 0, 0, 0.05); opacity: 0.9">裁剪模式,不缩放图片,只显示图片的底部区域</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; border-bottom: none; height: 62px; box-sizing: border-box; word-break: normal; border-top-color: rgba(0, 0, 0, 0.05); opacity: 0.9">&nbsp;</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 13.6px 20px 16px; -webkit-tap-highlight-color: transparent; border-bottom: none; height: 62px; box-sizing: border-box; word-break: normal; width: 10px; border-top-color: rgba(0, 0, 0, 0.05); opacity: 0.9">center</td>
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; border-bottom: none; height: 62px; box-sizing: border-box; word-break: normal; border-top-color: rgba(0, 0, 0, 0.05); opacity: 0.9">裁剪模式,不缩放图片,只显示图片的中间区域</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; border-bottom: none; height: 62px; box-sizing: border-box; word-break: normal; border-top-color: rgba(0, 0, 0, 0.05); opacity: 0.9">&nbsp;</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 13.6px 20px 16px; -webkit-tap-highlight-color: transparent; border-bottom: none; height: 62px; box-sizing: border-box; word-break: normal; width: 10px; border-top-color: rgba(0, 0, 0, 0.05); opacity: 0.9">left</td>
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; border-bottom: none; height: 62px; box-sizing: border-box; word-break: normal; border-top-color: rgba(0, 0, 0, 0.05); opacity: 0.9">裁剪模式,不缩放图片,只显示图片的左边区域</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; border-bottom: none; height: 62px; box-sizing: border-box; word-break: normal; border-top-color: rgba(0, 0, 0, 0.05); opacity: 0.9">&nbsp;</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 13.6px 20px 16px; -webkit-tap-highlight-color: transparent; border-bottom: none; height: 62px; box-sizing: border-box; word-break: normal; width: 10px; border-top-color: rgba(0, 0, 0, 0.05); opacity: 0.9">right</td>
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; border-bottom: none; height: 62px; box-sizing: border-box; word-break: normal; border-top-color: rgba(0, 0, 0, 0.05); opacity: 0.9">裁剪模式,不缩放图片,只显示图片的右边区域</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; border-bottom: none; height: 62px; box-sizing: border-box; word-break: normal; border-top-color: rgba(0, 0, 0, 0.05); opacity: 0.9">&nbsp;</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 13.6px 20px 16px; -webkit-tap-highlight-color: transparent; border-bottom: none; height: 62px; box-sizing: border-box; word-break: normal; width: 10px; border-top-color: rgba(0, 0, 0, 0.05); opacity: 0.9">top left</td>
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; border-bottom: none; height: 62px; box-sizing: border-box; word-break: normal; border-top-color: rgba(0, 0, 0, 0.05); opacity: 0.9">裁剪模式,不缩放图片,只显示图片的左上边区域</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; border-bottom: none; height: 62px; box-sizing: border-box; word-break: normal; border-top-color: rgba(0, 0, 0, 0.05); opacity: 0.9">&nbsp;</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 13.6px 20px 16px; -webkit-tap-highlight-color: transparent; border-bottom: none; height: 62px; box-sizing: border-box; word-break: normal; width: 10px; border-top-color: rgba(0, 0, 0, 0.05); opacity: 0.9">top right</td>
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; border-bottom: none; height: 62px; box-sizing: border-box; word-break: normal; border-top-color: rgba(0, 0, 0, 0.05); opacity: 0.9">裁剪模式,不缩放图片,只显示图片的右上边区域</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; border-bottom: none; height: 62px; box-sizing: border-box; word-break: normal; border-top-color: rgba(0, 0, 0, 0.05); opacity: 0.9">&nbsp;</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 13.6px 20px 16px; -webkit-tap-highlight-color: transparent; border-bottom: none; height: 62px; box-sizing: border-box; word-break: normal; width: 10px; border-top-color: rgba(0, 0, 0, 0.05); opacity: 0.9">bottom left</td>
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; border-bottom: none; height: 62px; box-sizing: border-box; word-break: normal; border-top-color: rgba(0, 0, 0, 0.05); opacity: 0.9">裁剪模式,不缩放图片,只显示图片的左下边区域</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; border-bottom: none; height: 62px; box-sizing: border-box; word-break: normal; border-top-color: rgba(0, 0, 0, 0.05); opacity: 0.9">&nbsp;</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 13.6px 20px 16px; -webkit-tap-highlight-color: transparent; border-bottom: none; height: 62px; box-sizing: border-box; word-break: normal; width: 10px; border-top-color: rgba(0, 0, 0, 0.05); opacity: 0.9; border-bottom-left-radius: 8px">bottom right</td>
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; border-bottom: none; height: 62px; box-sizing: border-box; word-break: normal; border-top-color: rgba(0, 0, 0, 0.05); opacity: 0.9">裁剪模式,不缩放图片,只显示图片的右下边区域</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; border-bottom: none; height: 62px; box-sizing: border-box; word-break: normal; border-top-color: rgba(0, 0, 0, 0.05); opacity: 0.9; border-bottom-right-radius: 8px">&nbsp;</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 13.6px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal; width: 10px">&nbsp;</td>
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">webp</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">boolean</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">false</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">默认不解析 webP 格式,只支持网络资源</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">2.9.0</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 13.6px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal; width: 10px">&nbsp;</td>
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">lazy-load</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">boolean</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">false</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">图片懒加载,在即将进入一定范围(上下三屏)时才开始加载</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">1.5.0</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 13.6px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal; width: 10px">&nbsp;</td>
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">show-menu-by-longpress</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">boolean</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">false</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">长按图片显示发送给朋友、收藏、保存图片、搜一搜、打开名片/前往群聊/打开小程序(若图片中包含对应二维码或小程序码)的菜单。</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">2.7.0</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 13.6px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal; width: 10px">&nbsp;</td>
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">binderror</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">eventhandle</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">&nbsp;</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">当错误发生时触发,event.detail = {errMsg}</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">1.0.0</td>
</tr>
<tr style="margin: 0; padding: 0; -webkit-tap-highlight-color: transparent">
<td style="margin: 0; padding: 20px 13.6px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal; width: 10px">&nbsp;</td>
<td style="margin: 0; padding: 20px 20px 20px 0; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">bindload</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">eventhandle</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">&nbsp;</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">否</td>
<td style="margin: 0; padding: 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">当图片载入完毕时触发,event.detail = {height, width}</td>
<td style="margin: 0; padding: 20px 0 20px 20px; -webkit-tap-highlight-color: transparent; color: rgba(53, 53, 53, 1); border-bottom-color: rgba(229, 229, 229, 1); height: 62px; box-sizing: border-box; word-break: normal">1.0.0</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p><img src="https://img2023.cnblogs.com/blog/2401301/202301/2401301-20230102165333893-1422218971.png" alt="" width="229" height="174" loading="lazy"></p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">image </span><span style="color: rgba(255, 0, 0, 1)">src</span><span style="color: rgba(0, 0, 255, 1)">="/images/rocket_top.png"</span><span style="color: rgba(255, 0, 0, 1)"> mode</span><span style="color: rgba(0, 0, 255, 1)">="aspectFit"</span><span style="color: rgba(255, 0, 0, 1)"> style</span><span style="color: rgba(0, 0, 255, 1)">="border: 1px red solid;"</span><span style="color: rgba(0, 0, 255, 1)">/&gt;</span></pre>
</div>
<p><span style="font-size: 16px">更多标签见官方文档:https://developers.weixin.qq.com/miniprogram/dev/framework/</span></p>
<p>&nbsp;</p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">image </span><span style="color: rgba(255, 0, 0, 1)">src</span><span style="color: rgba(0, 0, 255, 1)">="/images/haha.jpg"</span><span style="color: rgba(255, 0, 0, 1)"> mode</span><span style="color: rgba(0, 0, 255, 1)">="heightFix"</span><span style="color: rgba(255, 0, 0, 1)"> show-menu-by-longpress</span><span style="color: rgba(0, 0, 255, 1)">="true"</span><span style="color: rgba(0, 0, 255, 1)">&gt;&lt;/</span><span style="color: rgba(128, 0, 0, 1)">image</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">view </span><span style="color: rgba(255, 0, 0, 1)">style</span><span style="color: rgba(0, 0, 255, 1)">="height: 2000px; background: red;"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">image </span><span style="color: rgba(255, 0, 0, 1)">src</span><span style="color: rgba(0, 0, 255, 1)">="https://res.wx.qq.com/wxdoc/dist/assets/img/0.4cb08bb4.jpg"</span><span style="color: rgba(255, 0, 0, 1)"> lazy-load</span><span style="color: rgba(0, 0, 255, 1)">="true"</span><span style="color: rgba(0, 0, 255, 1)">&gt;&lt;/</span><span style="color: rgba(128, 0, 0, 1)">image</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span></pre>
</div>
<p>结果</p>
<p><img src="https://img2023.cnblogs.com/blog/63651/202304/63651-20230421084844168-1450288695.png" alt="" loading="lazy"></p>
<h2><strong>2.8、input</strong></h2>
<p>&nbsp;输入框</p>
<p><img src="https://img2023.cnblogs.com/blog/63651/202304/63651-20230420103825593-1290588532.png" alt="" width="843" height="744" loading="lazy"></p>
<p>&nbsp;更多:https://developers.weixin.qq.com/miniprogram/dev/component/input.html</p>
<p><img src="https://img2023.cnblogs.com/blog/63651/202304/63651-20230421090242153-255513602.png" alt="" width="1170" height="658" loading="lazy"></p>
<p>&nbsp;</p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">form</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
    <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">label </span><span style="color: rgba(255, 0, 0, 1)">for</span><span style="color: rgba(0, 0, 255, 1)">="txtId"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>帐号:<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">label</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
    <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">input </span><span style="color: rgba(255, 0, 0, 1)">id</span><span style="color: rgba(0, 0, 255, 1)">="txtId"</span><span style="color: rgba(255, 0, 0, 1)"> value</span><span style="color: rgba(0, 0, 255, 1)">="{{userId}}"</span><span style="color: rgba(255, 0, 0, 1)"> bindinput</span><span style="color: rgba(0, 0, 255, 1)">="inputHandle"</span><span style="color: rgba(255, 0, 0, 1)"> placeholder</span><span style="color: rgba(0, 0, 255, 1)">="请输入帐号"</span><span style="color: rgba(255, 0, 0, 1)"> auto-focus</span><span style="color: rgba(0, 0, 255, 1)">="true"</span><span style="color: rgba(0, 0, 255, 1)">/&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
    <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">label </span><span style="color: rgba(255, 0, 0, 1)">for</span><span style="color: rgba(0, 0, 255, 1)">="txtPhone"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>电话:<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">label</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
    <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">input </span><span style="color: rgba(255, 0, 0, 1)">id</span><span style="color: rgba(0, 0, 255, 1)">="txtPhone"</span><span style="color: rgba(255, 0, 0, 1)"> type</span><span style="color: rgba(0, 0, 255, 1)">="number"</span><span style="color: rgba(0, 0, 255, 1)">/&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
    <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">label </span><span style="color: rgba(255, 0, 0, 1)">for</span><span style="color: rgba(0, 0, 255, 1)">="txtPassword"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>密码:<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">label</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
    <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">input </span><span style="color: rgba(255, 0, 0, 1)">id</span><span style="color: rgba(0, 0, 255, 1)">="txtPassword"</span><span style="color: rgba(255, 0, 0, 1)"> password</span><span style="color: rgba(0, 0, 255, 1)">="true"</span><span style="color: rgba(0, 0, 255, 1)">/&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span><span style="color: rgba(0, 0, 0, 1)">
    {{userId}}
</span><span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">form</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span></pre>
</div>
<div class="cnblogs_code">
<pre>const page=<span style="color: rgba(0, 0, 0, 1)">{
data:{
    userId:</span>""<span style="color: rgba(0, 0, 0, 1)">
},
inputHandle(e){
    console.log(e.detail.value,e.detail.cursor,e.detail.keyCode);
    </span><span style="color: rgba(0, 0, 255, 1)">this</span><span style="color: rgba(0, 0, 0, 1)">.setData({userId:e.detail.value})
    </span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">当用户输入2个11时自动变成1个2</span>
    <span style="color: rgba(0, 0, 255, 1)">return</span> <span style="color: rgba(0, 0, 255, 1)">this</span>.data.userId.replace(/11/igm,'2'<span style="color: rgba(0, 0, 0, 1)">);
}
};
Page(page)</span></pre>
</div>
<p><img src="https://img2023.cnblogs.com/blog/63651/202304/63651-20230421091049744-1792300063.png" alt="" width="367" height="644" loading="lazy"></p>
<h2><strong>2.9、checkbox,checkbox-group</strong></h2>
<p>多选项目。</p>
<p><img src="https://img2023.cnblogs.com/blog/63651/202304/63651-20230420111329046-1880441277.png" alt="" loading="lazy"></p>
<p>&nbsp;更多:https://developers.weixin.qq.com/miniprogram/dev/component/checkbox.html</p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">form </span><span style="color: rgba(255, 0, 0, 1)">bindsubmit</span><span style="color: rgba(0, 0, 255, 1)">="submitHandle"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">checkbox-group </span><span style="color: rgba(255, 0, 0, 1)">bindchange</span><span style="color: rgba(0, 0, 255, 1)">="checkboxChange"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span><span style="color: rgba(0, 0, 0, 1)">
    爱好:
    </span><span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">label</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
      <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">checkbox </span><span style="color: rgba(255, 0, 0, 1)">value</span><span style="color: rgba(0, 0, 255, 1)">="阅读"</span><span style="color: rgba(255, 0, 0, 1)"> name</span><span style="color: rgba(0, 0, 255, 1)">="hobby"</span><span style="color: rgba(255, 0, 0, 1)"> checked</span><span style="color: rgba(0, 0, 255, 1)">="true"</span><span style="color: rgba(255, 0, 0, 1)"> color</span><span style="color: rgba(0, 0, 255, 1)">="orange"</span><span style="color: rgba(0, 0, 255, 1)">/&gt;</span><span style="color: rgba(0, 0, 0, 1)">阅读
    </span><span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">label</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
    <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">label</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
      <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">checkbox </span><span style="color: rgba(255, 0, 0, 1)">value</span><span style="color: rgba(0, 0, 255, 1)">="健身"</span><span style="color: rgba(255, 0, 0, 1)"> name</span><span style="color: rgba(0, 0, 255, 1)">="hobby"</span><span style="color: rgba(0, 0, 255, 1)">/&gt;</span><span style="color: rgba(0, 0, 0, 1)">健身
    </span><span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">label</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
    <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">label</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
      <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">checkbox </span><span style="color: rgba(255, 0, 0, 1)">value</span><span style="color: rgba(0, 0, 255, 1)">="电影"</span><span style="color: rgba(255, 0, 0, 1)"> name</span><span style="color: rgba(0, 0, 255, 1)">="hobby"</span><span style="color: rgba(0, 0, 255, 1)">/&gt;</span><span style="color: rgba(0, 0, 0, 1)">电影
    </span><span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">label</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
    <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">label</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
      <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">checkbox </span><span style="color: rgba(255, 0, 0, 1)">value</span><span style="color: rgba(0, 0, 255, 1)">="其它"</span><span style="color: rgba(255, 0, 0, 1)"> name</span><span style="color: rgba(0, 0, 255, 1)">="hobby"</span><span style="color: rgba(255, 0, 0, 1)"> disabled</span><span style="color: rgba(0, 0, 255, 1)">/&gt;</span>
    <span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">label</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">checkbox-group</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">button </span><span style="color: rgba(255, 0, 0, 1)">form-type</span><span style="color: rgba(0, 0, 255, 1)">="submit"</span><span style="color: rgba(255, 0, 0, 1)"> type</span><span style="color: rgba(0, 0, 255, 1)">="primary"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>提交<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">button</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">form</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span></pre>
</div>
<div class="cnblogs_code">
<pre>const page=<span style="color: rgba(0, 0, 0, 1)">{
submitHandle(e){
    console.log(e.detail);
},
checkboxChange(e){
    console.log(e.detail);
}
};
Page(page)</span></pre>
</div>
<p><img src="https://img2023.cnblogs.com/blog/63651/202304/63651-20230421094705663-923633680.png" alt="" width="1174" height="708" loading="lazy"></p>
<h2><strong>2.10、radio,radio-group</strong></h2>
<p>单选项目</p>
<p><img src="https://img2023.cnblogs.com/blog/63651/202304/63651-20230420135123514-1972163238.png" alt="" width="816" height="362" loading="lazy"></p>
<p>&nbsp;更多:https://developers.weixin.qq.com/miniprogram/dev/component/radio.html</p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">radio-group </span><span style="color: rgba(255, 0, 0, 1)">bindchange</span><span style="color: rgba(0, 0, 255, 1)">="radioChange"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span><span style="color: rgba(0, 0, 0, 1)">
性别:
</span><span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">label</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">radio </span><span style="color: rgba(255, 0, 0, 1)">value</span><span style="color: rgba(0, 0, 255, 1)">="男"</span><span style="color: rgba(255, 0, 0, 1)"> checked</span><span style="color: rgba(0, 0, 255, 1)">="true"</span><span style="color: rgba(0, 0, 255, 1)">&gt;&lt;/</span><span style="color: rgba(128, 0, 0, 1)">radio</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span><span style="color: rgba(0, 0, 0, 1)">男
</span><span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">label</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">label</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">radio </span><span style="color: rgba(255, 0, 0, 1)">value</span><span style="color: rgba(0, 0, 255, 1)">="女"</span><span style="color: rgba(0, 0, 255, 1)">&gt;&lt;/</span><span style="color: rgba(128, 0, 0, 1)">radio</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span><span style="color: rgba(0, 0, 0, 1)">女
</span><span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">label</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">radio-group</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span></pre>
</div>
<div class="cnblogs_code">
<pre>const page=<span style="color: rgba(0, 0, 0, 1)">{
radioChange(e){
    console.log(e.detail.value);
}
};
Page(page)</span></pre>
</div>
<p><img src="https://img2023.cnblogs.com/blog/63651/202304/63651-20230421095315700-1093164535.png" alt="" width="1187" height="647" loading="lazy"></p>
<h2>2.11、slider</h2>
<p>滑动选择器</p>
<p><img src="https://img2023.cnblogs.com/blog/63651/202304/63651-20230420150145653-671681377.png" alt="" width="783" height="666" loading="lazy"></p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">slider </span><span style="color: rgba(255, 0, 0, 1)">bindchange</span><span style="color: rgba(0, 0, 255, 1)">="sliderChange1"</span><span style="color: rgba(255, 0, 0, 1)"> show-value</span><span style="color: rgba(0, 0, 255, 1)">="true"</span><span style="color: rgba(255, 0, 0, 1)"> max</span><span style="color: rgba(0, 0, 255, 1)">="200"</span><span style="color: rgba(255, 0, 0, 1)"> min</span><span style="color: rgba(0, 0, 255, 1)">="100"</span><span style="color: rgba(255, 0, 0, 1)"> step</span><span style="color: rgba(0, 0, 255, 1)">="5"</span><span style="color: rgba(0, 0, 255, 1)">/&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">slider </span><span style="color: rgba(255, 0, 0, 1)">bindchange</span><span style="color: rgba(0, 0, 255, 1)">="sliderChange2"</span><span style="color: rgba(255, 0, 0, 1)"> bindchanging</span><span style="color: rgba(0, 0, 255, 1)">="changingHandle"</span><span style="color: rgba(255, 0, 0, 1)">show-value</span><span style="color: rgba(0, 0, 255, 1)">="true"</span><span style="color: rgba(0, 0, 255, 1)">/&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">slider </span><span style="color: rgba(255, 0, 0, 1)">bindchange</span><span style="color: rgba(0, 0, 255, 1)">="sliderChange3"</span><span style="color: rgba(255, 0, 0, 1)">show-value</span><span style="color: rgba(0, 0, 255, 1)">="true"</span><span style="color: rgba(0, 0, 255, 1)">/&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">slider </span><span style="color: rgba(255, 0, 0, 1)">bindchange</span><span style="color: rgba(0, 0, 255, 1)">="sliderChange4"</span><span style="color: rgba(255, 0, 0, 1)">show-value</span><span style="color: rgba(0, 0, 255, 1)">="true"</span><span style="color: rgba(0, 0, 255, 1)">/&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span></pre>
</div>
<div class="cnblogs_code">
<pre>const page=<span style="color: rgba(0, 0, 0, 1)">{
};

</span><span style="color: rgba(0, 128, 0, 1)">/*</span><span style="color: rgba(0, 128, 0, 1)">解决方法1 </span><span style="color: rgba(0, 128, 0, 1)">*/</span>
<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> for(var i=1;i&lt;5;i++){</span><span style="color: rgba(0, 128, 0, 1)">
//</span><span style="color: rgba(0, 128, 0, 1)">   (function(n){</span><span style="color: rgba(0, 128, 0, 1)">
//</span><span style="color: rgba(0, 128, 0, 1)">   page[`sliderChange${n}`]=function(e){</span><span style="color: rgba(0, 128, 0, 1)">
//</span><span style="color: rgba(0, 128, 0, 1)">       console.log(`第${n}个滑块,当前值:${e.detail.value}`);</span><span style="color: rgba(0, 128, 0, 1)">
//</span><span style="color: rgba(0, 128, 0, 1)">   }</span><span style="color: rgba(0, 128, 0, 1)">
//</span><span style="color: rgba(0, 128, 0, 1)">   })(i);</span><span style="color: rgba(0, 128, 0, 1)">
//</span><span style="color: rgba(0, 128, 0, 1)"> }</span><span style="color: rgba(0, 128, 0, 1)">
/*</span><span style="color: rgba(0, 128, 0, 1)">解决方法2 </span><span style="color: rgba(0, 128, 0, 1)">*/</span>
<span style="color: rgba(0, 0, 255, 1)">for</span>(let i=1;i&lt;5;i++<span style="color: rgba(0, 0, 0, 1)">){
    page[`sliderChange${i}`]</span>=<span style="color: rgba(0, 0, 255, 1)">function</span><span style="color: rgba(0, 0, 0, 1)">(e){
      console.log(`第${i}个滑块,当前值:${e.detail.value}`);
    }
}

page.changingHandle</span>=<span style="color: rgba(0, 0, 255, 1)">function</span><span style="color: rgba(0, 0, 0, 1)">(e){
console.log(e.detail.value);
}

Page(page)</span></pre>
</div>
<p><img src="https://img2023.cnblogs.com/blog/63651/202304/63651-20230421101014234-1060251730.png" alt="" loading="lazy"></p>
<h2>2.12、form</h2>
<p>表单</p>
<p>表单。将组件内的用户输入的switch&nbsp;input&nbsp;checkbox&nbsp;slider&nbsp;radio&nbsp;picker&nbsp;提交。</p>
<p>当点击&nbsp;form&nbsp;表单中 form-type 为 submit 的&nbsp;button&nbsp;组件时,会将表单组件中的 value 值进行提交,需要在表单组件中加上 name 来作为 key。</p>
<p><img src="https://img2023.cnblogs.com/blog/63651/202304/63651-20230421091228056-1927968020.png" alt="" width="846" height="526" loading="lazy"></p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">form </span><span style="color: rgba(255, 0, 0, 1)">bindsubmit</span><span style="color: rgba(0, 0, 255, 1)">="submitHandle"</span><span style="color: rgba(255, 0, 0, 1)"> bindreset</span><span style="color: rgba(0, 0, 255, 1)">="resetHandle"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
    <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">label </span><span style="color: rgba(255, 0, 0, 1)">for</span><span style="color: rgba(0, 0, 255, 1)">="txtId"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>帐号:<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">label</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
    <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">input </span><span style="color: rgba(255, 0, 0, 1)">name</span><span style="color: rgba(0, 0, 255, 1)">="userId"</span><span style="color: rgba(255, 0, 0, 1)"> id</span><span style="color: rgba(0, 0, 255, 1)">="txtId"</span><span style="color: rgba(255, 0, 0, 1)"> value</span><span style="color: rgba(0, 0, 255, 1)">="{{userId}}"</span><span style="color: rgba(255, 0, 0, 1)"> bindinput</span><span style="color: rgba(0, 0, 255, 1)">="inputHandle"</span><span style="color: rgba(255, 0, 0, 1)"> placeholder</span><span style="color: rgba(0, 0, 255, 1)">="请输入帐号"</span><span style="color: rgba(255, 0, 0, 1)"> auto-focus</span><span style="color: rgba(0, 0, 255, 1)">="true"</span><span style="color: rgba(0, 0, 255, 1)">/&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
    <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">label </span><span style="color: rgba(255, 0, 0, 1)">for</span><span style="color: rgba(0, 0, 255, 1)">="txtPhone"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>电话:<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">label</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
    <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">input </span><span style="color: rgba(255, 0, 0, 1)">name</span><span style="color: rgba(0, 0, 255, 1)">="userPhone"</span><span style="color: rgba(255, 0, 0, 1)"> id</span><span style="color: rgba(0, 0, 255, 1)">="txtPhone"</span><span style="color: rgba(255, 0, 0, 1)"> type</span><span style="color: rgba(0, 0, 255, 1)">="number"</span><span style="color: rgba(0, 0, 255, 1)">/&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
    <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">label </span><span style="color: rgba(255, 0, 0, 1)">for</span><span style="color: rgba(0, 0, 255, 1)">="txtPassword"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>密码:<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">label</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
    <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">input </span><span style="color: rgba(255, 0, 0, 1)">name</span><span style="color: rgba(0, 0, 255, 1)">="userPwd"</span><span style="color: rgba(255, 0, 0, 1)"> id</span><span style="color: rgba(0, 0, 255, 1)">="txtPassword"</span><span style="color: rgba(255, 0, 0, 1)"> password</span><span style="color: rgba(0, 0, 255, 1)">="true"</span><span style="color: rgba(0, 0, 255, 1)">/&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
    <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">button </span><span style="color: rgba(255, 0, 0, 1)">type</span><span style="color: rgba(0, 0, 255, 1)">="primary"</span><span style="color: rgba(255, 0, 0, 1)"> form-type</span><span style="color: rgba(0, 0, 255, 1)">="submit"</span><span style="color: rgba(255, 0, 0, 1)"> size</span><span style="color: rgba(0, 0, 255, 1)">="mini"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>提交<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">button</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
    <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">button </span><span style="color: rgba(255, 0, 0, 1)">type</span><span style="color: rgba(0, 0, 255, 1)">="warn"</span><span style="color: rgba(255, 0, 0, 1)"> form-type</span><span style="color: rgba(0, 0, 255, 1)">="reset"</span><span style="color: rgba(255, 0, 0, 1)"> size</span><span style="color: rgba(0, 0, 255, 1)">="mini"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>重置<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">button</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span><span style="color: rgba(0, 0, 0, 1)">
    {{userId}}
</span><span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">form</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span></pre>
</div>
<div class="cnblogs_code">
<pre>const page=<span style="color: rgba(0, 0, 0, 1)">{
data:{
    userId:</span>""<span style="color: rgba(0, 0, 0, 1)">
},
inputHandle(e){
    console.log(e.detail.value,e.detail.cursor,e.detail.keyCode);
    </span><span style="color: rgba(0, 0, 255, 1)">this</span><span style="color: rgba(0, 0, 0, 1)">.setData({userId:e.detail.value})
    </span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">当用户输入2个11时自动变成1个2</span>
    <span style="color: rgba(0, 0, 255, 1)">return</span> <span style="color: rgba(0, 0, 255, 1)">this</span>.data.userId.replace(/11/igm,'2'<span style="color: rgba(0, 0, 0, 1)">);
},
submitHandle(e){
    console.log(e);
},
resetHandle(e){
    console.log(e);
}
};
Page(page)</span></pre>
</div>
<p><img src="https://img2023.cnblogs.com/blog/63651/202304/63651-20230421093220565-87902843.png" alt="" loading="lazy"></p>
<h1>三、WXML</h1>
<h2>&nbsp;3.1、整体介绍</h2>
<p>WXML(WeiXin Markup Language)是框架设计的一套标签语言,结合基础组件、事件系统,可以构建出页面的结构。</p>
<p>用以下一些简单的例子来看看 WXML 具有什么能力:</p>
<h3 id="数据绑定">3.1.1、数据绑定</h3>
<div class="language-html extra-class">
<pre class="language-html"><code><span class="token comment">&lt;!--wxml--&gt;
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;view<span class="token punctuation">&gt; {{message}} <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/view<span class="token punctuation">&gt;
</span></span></span></span></span></span></span></span></span></code></pre>
</div>
<div class="language-js extra-class">
<pre class="language-js"><code><span class="token comment">// page.js
<span class="token function">Page<span class="token punctuation">(<span class="token punctuation">{
data<span class="token operator">: <span class="token punctuation">{
    message<span class="token operator">: <span class="token string">'Hello MINA!'
<span class="token punctuation">}
<span class="token punctuation">}<span class="token punctuation">)
</span></span></span></span></span></span></span></span></span></span></span></code></pre>
</div>
<h3 id="列表渲染">3.1.2、列表渲染</h3>
<div class="language-html extra-class">
<pre class="language-html"><code><span class="token comment">&lt;!--wxml--&gt;
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;view <span class="token attr-name"><span class="token namespace">wx:for<span class="token attr-value"><span class="token punctuation attr-equals">=<span class="token punctuation">"{{array}}<span class="token punctuation">"<span class="token punctuation">&gt; {{item}} <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/view<span class="token punctuation">&gt;
</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></code></pre>
</div>
<div class="language-js extra-class">
<pre class="language-js"><code><span class="token comment">// page.js
<span class="token function">Page<span class="token punctuation">(<span class="token punctuation">{
data<span class="token operator">: <span class="token punctuation">{
    array<span class="token operator">: <span class="token punctuation">[<span class="token number">1<span class="token punctuation">, <span class="token number">2<span class="token punctuation">, <span class="token number">3<span class="token punctuation">, <span class="token number">4<span class="token punctuation">, <span class="token number">5<span class="token punctuation">]
<span class="token punctuation">}
<span class="token punctuation">}<span class="token punctuation">)
</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></code></pre>
</div>
<h3 id="条件渲染">3.1.3、条件渲染</h3>
<div class="language-html extra-class">
<pre class="language-html"><code><span class="token comment">&lt;!--wxml--&gt;
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;view <span class="token attr-name"><span class="token namespace">wx:if<span class="token attr-value"><span class="token punctuation attr-equals">=<span class="token punctuation">"{{view == <span class="token punctuation">'WEBVIEW<span class="token punctuation">'}}<span class="token punctuation">"<span class="token punctuation">&gt; WEBVIEW <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/view<span class="token punctuation">&gt;
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;view <span class="token attr-name"><span class="token namespace">wx:elif<span class="token attr-value"><span class="token punctuation attr-equals">=<span class="token punctuation">"{{view == <span class="token punctuation">'APP<span class="token punctuation">'}}<span class="token punctuation">"<span class="token punctuation">&gt; APP <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/view<span class="token punctuation">&gt;
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;view <span class="token attr-name"><span class="token namespace">wx:else<span class="token attr-value"><span class="token punctuation attr-equals">=<span class="token punctuation">"{{view == <span class="token punctuation">'MINA<span class="token punctuation">'}}<span class="token punctuation">"<span class="token punctuation">&gt; MINA <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/view<span class="token punctuation">&gt;
</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></code></pre>
</div>
<div class="language-js extra-class">
<pre class="language-js"><code><span class="token comment">// page.js
<span class="token function">Page<span class="token punctuation">(<span class="token punctuation">{
data<span class="token operator">: <span class="token punctuation">{
    view<span class="token operator">: <span class="token string">'MINA'
<span class="token punctuation">}
<span class="token punctuation">}<span class="token punctuation">)<br></span></span></span></span></span></span></span></span></span></span></span></code></pre>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">label </span><span style="color: rgba(255, 0, 0, 1)">for</span><span style="color: rgba(0, 0, 255, 1)">="name"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>姓名首字母:<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">label</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">input </span><span style="color: rgba(255, 0, 0, 1)">id</span><span style="color: rgba(0, 0, 255, 1)">="name"</span><span style="color: rgba(255, 0, 0, 1)"> value</span><span style="color: rgba(0, 0, 255, 1)">="{{name}}"</span><span style="color: rgba(255, 0, 0, 1)"> bindinput</span><span style="color: rgba(0, 0, 255, 1)">="inputHandle"</span><span style="color: rgba(0, 0, 255, 1)">/&gt;</span><span style="color: rgba(0, 0, 0, 1)">
{{name}}
</span><span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">view </span><span style="color: rgba(255, 0, 0, 1)">wx:if</span><span style="color: rgba(0, 0, 255, 1)">="{{name==='t'}}"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>tom<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">view </span><span style="color: rgba(255, 0, 0, 1)">wx:elif</span><span style="color: rgba(0, 0, 255, 1)">="{{name==='j'}}"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>jack<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">view </span><span style="color: rgba(255, 0, 0, 1)">wx:else</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>请输入姓名的首字母,比如t,j<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span></pre>
</div>
<div class="cnblogs_code">
<pre>const page=<span style="color: rgba(0, 0, 0, 1)">{
data:{
    arr1:[</span>1,2,3,4,5<span style="color: rgba(0, 0, 0, 1)">],
    name:</span>""<span style="color: rgba(0, 0, 0, 1)">
},
inputHandle(e){
    </span><span style="color: rgba(0, 0, 255, 1)">this</span><span style="color: rgba(0, 0, 0, 1)">.setData({name:e.detail.value});
}
};
Page(page)</span></pre>
</div>
<p><img src="https://img2023.cnblogs.com/blog/63651/202304/63651-20230420153113083-229735310.png" alt="" width="359" height="632" loading="lazy"></p>
</div>
<h3 id="模板">3.1.4、模板</h3>
<div class="language-html extra-class">
<pre class="language-html"><code><span class="token comment">&lt;!--wxml--&gt;
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;template <span class="token attr-name">name<span class="token attr-value"><span class="token punctuation attr-equals">=<span class="token punctuation">"staffName<span class="token punctuation">"<span class="token punctuation">&gt;
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;view<span class="token punctuation">&gt;
    FirstName: {{firstName}}, LastName: {{lastName}}
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/view<span class="token punctuation">&gt;
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/template<span class="token punctuation">&gt;

<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;template <span class="token attr-name">is<span class="token attr-value"><span class="token punctuation attr-equals">=<span class="token punctuation">"staffName<span class="token punctuation">" <span class="token attr-name">data<span class="token attr-value"><span class="token punctuation attr-equals">=<span class="token punctuation">"{{...staffA}}<span class="token punctuation">"<span class="token punctuation">&gt;<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/template<span class="token punctuation">&gt;
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;template <span class="token attr-name">is<span class="token attr-value"><span class="token punctuation attr-equals">=<span class="token punctuation">"staffName<span class="token punctuation">" <span class="token attr-name">data<span class="token attr-value"><span class="token punctuation attr-equals">=<span class="token punctuation">"{{...staffB}}<span class="token punctuation">"<span class="token punctuation">&gt;<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/template<span class="token punctuation">&gt;
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;template <span class="token attr-name">is<span class="token attr-value"><span class="token punctuation attr-equals">=<span class="token punctuation">"staffName<span class="token punctuation">" <span class="token attr-name">data<span class="token attr-value"><span class="token punctuation attr-equals">=<span class="token punctuation">"{{...staffC}}<span class="token punctuation">"<span class="token punctuation">&gt;<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/template<span class="token punctuation">&gt;
</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></code></pre>
</div>
<div class="language-js extra-class">
<pre class="language-js"><code><span class="token comment">// page.js
<span class="token function">Page<span class="token punctuation">(<span class="token punctuation">{
data<span class="token operator">: <span class="token punctuation">{
    staffA<span class="token operator">: <span class="token punctuation">{firstName<span class="token operator">: <span class="token string">'Hulk'<span class="token punctuation">, lastName<span class="token operator">: <span class="token string">'Hu'<span class="token punctuation">}<span class="token punctuation">,
    staffB<span class="token operator">: <span class="token punctuation">{firstName<span class="token operator">: <span class="token string">'Shang'<span class="token punctuation">, lastName<span class="token operator">: <span class="token string">'You'<span class="token punctuation">}<span class="token punctuation">,
    staffC<span class="token operator">: <span class="token punctuation">{firstName<span class="token operator">: <span class="token string">'Gideon'<span class="token punctuation">, lastName<span class="token operator">: <span class="token string">'Lin'<span class="token punctuation">}
<span class="token punctuation">}
<span class="token punctuation">}<span class="token punctuation">)</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></code></pre>
</div>
<p><span style="font-size: 14pt">示例:</span></p>
<p>&nbsp;</p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">template </span><span style="color: rgba(255, 0, 0, 1)">name</span><span style="color: rgba(0, 0, 255, 1)">="staff"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
    <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>员工名片<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
    <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>姓名:{{firstname}} {{lastname}} <span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">template</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>

<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">template </span><span style="color: rgba(255, 0, 0, 1)">is</span><span style="color: rgba(0, 0, 255, 1)">="staff"</span><span style="color: rgba(255, 0, 0, 1)"> data</span><span style="color: rgba(0, 0, 255, 1)">="{{...staffA}}"</span> <span style="color: rgba(0, 0, 255, 1)">&gt;&lt;/</span><span style="color: rgba(128, 0, 0, 1)">template</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">template </span><span style="color: rgba(255, 0, 0, 1)">is</span><span style="color: rgba(0, 0, 255, 1)">="staff"</span><span style="color: rgba(255, 0, 0, 1)"> data</span><span style="color: rgba(0, 0, 255, 1)">="{{...staffB}}"</span> <span style="color: rgba(0, 0, 255, 1)">&gt;&lt;/</span><span style="color: rgba(128, 0, 0, 1)">template</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">template </span><span style="color: rgba(255, 0, 0, 1)">is</span><span style="color: rgba(0, 0, 255, 1)">="staff"</span><span style="color: rgba(255, 0, 0, 1)"> data</span><span style="color: rgba(0, 0, 255, 1)">="{{...staffC}}"</span> <span style="color: rgba(0, 0, 255, 1)">&gt;&lt;/</span><span style="color: rgba(128, 0, 0, 1)">template</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span></pre>
</div>
<div class="cnblogs_code">
<pre>const page=<span style="color: rgba(0, 0, 0, 1)">{
data:{
    staffA:{firstname:</span>"jack",lastname:"ma"<span style="color: rgba(0, 0, 0, 1)">},
    staffB:{firstname:</span>"rose",lastname:"li"<span style="color: rgba(0, 0, 0, 1)">},
    staffC:{firstname:</span>"mark",lastname:"liu"<span style="color: rgba(0, 0, 0, 1)">},
},
};
Page(page)</span></pre>
</div>
<p><span style="font-size: 14pt">结果:</span></p>
<p><img src="https://img2023.cnblogs.com/blog/63651/202304/63651-20230420160029185-1134034171.png" alt="" loading="lazy"></p>
<h2>&nbsp;3.2、数据绑定</h2>
<p>WXML 中的动态数据均来自对应 Page 的 data。</p>
<h3 id="简单绑定">3.2.1、简单绑定</h3>
<p>数据绑定使用 Mustache 语法(双大括号)将变量包起来,可以作用于:</p>
<h4 id="内容">内容</h4>
<div class="language-html extra-class">
<pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;view<span class="token punctuation">&gt; {{ message }} <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/view<span class="token punctuation">&gt;
</span></span></span></span></span></span></span></span></code></pre>
</div>
<div class="language-js extra-class">
<pre class="language-js"><code><span class="token function">Page<span class="token punctuation">(<span class="token punctuation">{
data<span class="token operator">: <span class="token punctuation">{
    message<span class="token operator">: <span class="token string">'Hello MINA!'
<span class="token punctuation">}
<span class="token punctuation">}<span class="token punctuation">)
</span></span></span></span></span></span></span></span></span></span></code></pre>
</div>
<h4 id="组件属性-需要在双引号之内">组件属性(需要在双引号之内)</h4>
<div class="language-html extra-class">
<pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;view <span class="token attr-name">id<span class="token attr-value"><span class="token punctuation attr-equals">=<span class="token punctuation">"item-{{id}}<span class="token punctuation">"<span class="token punctuation">&gt; <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/view<span class="token punctuation">&gt;
</span></span></span></span></span></span></span></span></span></span></span></span></span></code></pre>
</div>
<div class="language-js extra-class">
<pre class="language-js"><code><span class="token function">Page<span class="token punctuation">(<span class="token punctuation">{
data<span class="token operator">: <span class="token punctuation">{
    id<span class="token operator">: <span class="token number">0
<span class="token punctuation">}
<span class="token punctuation">}<span class="token punctuation">)
</span></span></span></span></span></span></span></span></span></span></code></pre>
</div>
<h4 id="控制属性-需要在双引号之内">控制属性(需要在双引号之内)</h4>
<div class="language-html extra-class">
<pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;view <span class="token attr-name"><span class="token namespace">wx:if<span class="token attr-value"><span class="token punctuation attr-equals">=<span class="token punctuation">"{{condition}}<span class="token punctuation">"<span class="token punctuation">&gt; <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/view<span class="token punctuation">&gt;
</span></span></span></span></span></span></span></span></span></span></span></span></span></span></code></pre>
</div>
<div class="language-js extra-class">
<pre class="language-js"><code><span class="token function">Page<span class="token punctuation">(<span class="token punctuation">{
data<span class="token operator">: <span class="token punctuation">{
    condition<span class="token operator">: <span class="token boolean">true
<span class="token punctuation">}
<span class="token punctuation">}<span class="token punctuation">)
</span></span></span></span></span></span></span></span></span></span></code></pre>
</div>
<h4 id="关键字-需要在双引号之内">关键字(需要在双引号之内)</h4>
<p><code>true</code>:boolean 类型的 true,代表真值。</p>
<p><code>false</code>: boolean 类型的 false,代表假值。</p>
<div class="language-html extra-class">
<pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;checkbox <span class="token attr-name">checked<span class="token attr-value"><span class="token punctuation attr-equals">=<span class="token punctuation">"{{false}}<span class="token punctuation">"<span class="token punctuation">&gt; <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/checkbox<span class="token punctuation">&gt;
</span></span></span></span></span></span></span></span></span></span></span></span></span></code></pre>
</div>
<p><em><strong>特别注意:不要直接写&nbsp;<code>checked="false"</code>,其计算结果是一个字符串,转成 boolean 类型后代表真值。</strong></em></p>
<h3 id="运算">3.2.2、运算</h3>
<p>可以在&nbsp;<code>{{}}</code>&nbsp;内进行简单的运算,支持的有如下几种方式:</p>
<h4 id="三元运算">三元运算</h4>
<div class="language-html extra-class">
<pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;view <span class="token attr-name">hidden<span class="token attr-value"><span class="token punctuation attr-equals">=<span class="token punctuation">"{{flag ? true : false}}<span class="token punctuation">"<span class="token punctuation">&gt; Hidden <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/view<span class="token punctuation">&gt;
</span></span></span></span></span></span></span></span></span></span></span></span></span></code></pre>
</div>
<h4 id="算数运算">算数运算</h4>
<div class="language-html extra-class">
<pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;view<span class="token punctuation">&gt; {{a + b}} + {{c}} + d <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/view<span class="token punctuation">&gt;
</span></span></span></span></span></span></span></span></code></pre>
</div>
<div class="language-js extra-class">
<pre class="language-js"><code><span class="token function">Page<span class="token punctuation">(<span class="token punctuation">{
data<span class="token operator">: <span class="token punctuation">{
    a<span class="token operator">: <span class="token number">1<span class="token punctuation">,
    b<span class="token operator">: <span class="token number">2<span class="token punctuation">,
    c<span class="token operator">: <span class="token number">3
<span class="token punctuation">}
<span class="token punctuation">}<span class="token punctuation">)
</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></code></pre>
</div>
<p>view中的内容为&nbsp;<code>3 + 3 + d</code>。</p>
<h4 id="逻辑判断">逻辑判断</h4>
<div class="language-html extra-class">
<pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;view <span class="token attr-name"><span class="token namespace">wx:if<span class="token attr-value"><span class="token punctuation attr-equals">=<span class="token punctuation">"{{length &gt; 5}}<span class="token punctuation">"<span class="token punctuation">&gt; <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/view<span class="token punctuation">&gt;
</span></span></span></span></span></span></span></span></span></span></span></span></span></span></code></pre>
</div>
<h4 id="字符串运算">字符串运算</h4>
<div class="language-html extra-class">
<pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;view<span class="token punctuation">&gt;{{"hello" + name}}<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/view<span class="token punctuation">&gt;
</span></span></span></span></span></span></span></span></code></pre>
</div>
<div class="language-javascript extra-class">
<pre class="language-javascript"><code><span class="token function">Page<span class="token punctuation">(<span class="token punctuation">{
data<span class="token operator">:<span class="token punctuation">{
    name<span class="token operator">: <span class="token string">'MINA'
<span class="token punctuation">}
<span class="token punctuation">}<span class="token punctuation">)
</span></span></span></span></span></span></span></span></span></span></code></pre>
</div>
<h4 id="数据路径运算">数据路径运算</h4>
<div class="language-html extra-class">
<pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;view<span class="token punctuation">&gt;{{object.key}} {{array}}<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/view<span class="token punctuation">&gt;
</span></span></span></span></span></span></span></span></code></pre>
</div>
<div class="language-js extra-class">
<pre class="language-js"><code><span class="token function">Page<span class="token punctuation">(<span class="token punctuation">{
data<span class="token operator">: <span class="token punctuation">{
    object<span class="token operator">: <span class="token punctuation">{
      key<span class="token operator">: <span class="token string">'Hello '
    <span class="token punctuation">}<span class="token punctuation">,
    array<span class="token operator">: <span class="token punctuation">[<span class="token string">'MINA'<span class="token punctuation">]
<span class="token punctuation">}
<span class="token punctuation">}<span class="token punctuation">)
</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></code></pre>
</div>
<h3 id="组合">3.2.3、组合</h3>
<p>也可以在 Mustache 内直接进行组合,构成新的对象或者数组。</p>
<h4 id="数组">数组</h4>
<div class="language-html extra-class">
<pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;view <span class="token attr-name"><span class="token namespace">wx:for<span class="token attr-value"><span class="token punctuation attr-equals">=<span class="token punctuation">"{{}}<span class="token punctuation">"<span class="token punctuation">&gt; {{item}} <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/view<span class="token punctuation">&gt;
</span></span></span></span></span></span></span></span></span></span></span></span></span></span></code></pre>
</div>
<div class="language-js extra-class">
<pre class="language-js"><code><span class="token function">Page<span class="token punctuation">(<span class="token punctuation">{
data<span class="token operator">: <span class="token punctuation">{
    zero<span class="token operator">: <span class="token number">0
<span class="token punctuation">}
<span class="token punctuation">}<span class="token punctuation">)
</span></span></span></span></span></span></span></span></span></span></code></pre>
</div>
<p>最终组合成数组<code></code>。</p>
<h4 id="对象">对象</h4>
<div class="language-html extra-class">
<pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;template <span class="token attr-name">is<span class="token attr-value"><span class="token punctuation attr-equals">=<span class="token punctuation">"objectCombine<span class="token punctuation">" <span class="token attr-name">data<span class="token attr-value"><span class="token punctuation attr-equals">=<span class="token punctuation">"{{for: a, bar: b}}<span class="token punctuation">"<span class="token punctuation">&gt;<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/template<span class="token punctuation">&gt;
</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></code></pre>
</div>
<div class="language-js extra-class">
<pre class="language-js"><code><span class="token function">Page<span class="token punctuation">(<span class="token punctuation">{
data<span class="token operator">: <span class="token punctuation">{
    a<span class="token operator">: <span class="token number">1<span class="token punctuation">,
    b<span class="token operator">: <span class="token number">2
<span class="token punctuation">}
<span class="token punctuation">}<span class="token punctuation">)
</span></span></span></span></span></span></span></span></span></span></span></span></span></code></pre>
</div>
<p>最终组合成的对象是&nbsp;<code>{for: 1, bar: 2}</code></p>
<p>也可以用扩展运算符&nbsp;<code>...</code>&nbsp;来将一个对象展开</p>
<div class="language-html extra-class">
<pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;template <span class="token attr-name">is<span class="token attr-value"><span class="token punctuation attr-equals">=<span class="token punctuation">"objectCombine<span class="token punctuation">" <span class="token attr-name">data<span class="token attr-value"><span class="token punctuation attr-equals">=<span class="token punctuation">"{{...obj1, ...obj2, e: 5}}<span class="token punctuation">"<span class="token punctuation">&gt;<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/template<span class="token punctuation">&gt;
</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></code></pre>
</div>
<div class="language-js extra-class">
<pre class="language-js"><code><span class="token function">Page<span class="token punctuation">(<span class="token punctuation">{
data<span class="token operator">: <span class="token punctuation">{
    obj1<span class="token operator">: <span class="token punctuation">{
      a<span class="token operator">: <span class="token number">1<span class="token punctuation">,
      b<span class="token operator">: <span class="token number">2
    <span class="token punctuation">}<span class="token punctuation">,
    obj2<span class="token operator">: <span class="token punctuation">{
      c<span class="token operator">: <span class="token number">3<span class="token punctuation">,
      d<span class="token operator">: <span class="token number">4
    <span class="token punctuation">}
<span class="token punctuation">}
<span class="token punctuation">}<span class="token punctuation">)
</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></code></pre>
</div>
<p>最终组合成的对象是&nbsp;<code>{a: 1, b: 2, c: 3, d: 4, e: 5}</code>。</p>
<p>如果对象的 key 和 value 相同,也可以间接地表达。</p>
<div class="language-html extra-class">
<pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;template <span class="token attr-name">is<span class="token attr-value"><span class="token punctuation attr-equals">=<span class="token punctuation">"objectCombine<span class="token punctuation">" <span class="token attr-name">data<span class="token attr-value"><span class="token punctuation attr-equals">=<span class="token punctuation">"{{foo, bar}}<span class="token punctuation">"<span class="token punctuation">&gt;<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/template<span class="token punctuation">&gt;
</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></code></pre>
</div>
<div class="language-js extra-class">
<pre class="language-js"><code><span class="token function">Page<span class="token punctuation">(<span class="token punctuation">{
data<span class="token operator">: <span class="token punctuation">{
    foo<span class="token operator">: <span class="token string">'my-foo'<span class="token punctuation">,
    bar<span class="token operator">: <span class="token string">'my-bar'
<span class="token punctuation">}
<span class="token punctuation">}<span class="token punctuation">)
</span></span></span></span></span></span></span></span></span></span></span></span></span></code></pre>
</div>
<p>最终组合成的对象是&nbsp;<code>{foo: 'my-foo', bar:'my-bar'}</code>。</p>
<p><strong>注意</strong>:上述方式可以随意组合,但是如有存在变量名相同的情况,后边的会覆盖前面,如:</p>
<div class="language-html extra-class">
<pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;template <span class="token attr-name">is<span class="token attr-value"><span class="token punctuation attr-equals">=<span class="token punctuation">"objectCombine<span class="token punctuation">" <span class="token attr-name">data<span class="token attr-value"><span class="token punctuation attr-equals">=<span class="token punctuation">"{{...obj1, ...obj2, a, c: 6}}<span class="token punctuation">"<span class="token punctuation">&gt;<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/template<span class="token punctuation">&gt;
</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></code></pre>
</div>
<div class="language-js extra-class">
<pre class="language-js"><code><span class="token function">Page<span class="token punctuation">(<span class="token punctuation">{
data<span class="token operator">: <span class="token punctuation">{
    obj1<span class="token operator">: <span class="token punctuation">{
      a<span class="token operator">: <span class="token number">1<span class="token punctuation">,
      b<span class="token operator">: <span class="token number">2
    <span class="token punctuation">}<span class="token punctuation">,
    obj2<span class="token operator">: <span class="token punctuation">{
      b<span class="token operator">: <span class="token number">3<span class="token punctuation">,
      c<span class="token operator">: <span class="token number">4
    <span class="token punctuation">}<span class="token punctuation">,
    a<span class="token operator">: <span class="token number">5
<span class="token punctuation">}
<span class="token punctuation">}<span class="token punctuation">)
</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></code></pre>
</div>
<p>最终组合成的对象是&nbsp;<code>{a: 5, b: 3, c: 6}</code>。</p>
<p><strong>注意:</strong>&nbsp;花括号和引号之间如果有空格,将最终被解析成为字符串</p>
<div class="language-html extra-class">
<pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;view <span class="token attr-name"><span class="token namespace">wx:for<span class="token attr-value"><span class="token punctuation attr-equals">=<span class="token punctuation">"{{}} <span class="token punctuation">"<span class="token punctuation">&gt;
{{item}}
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/view<span class="token punctuation">&gt;
</span></span></span></span></span></span></span></span></span></span></span></span></span></span></code></pre>
</div>
<p>等同于</p>
<div class="language-html extra-class">
<pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;view <span class="token attr-name"><span class="token namespace">wx:for<span class="token attr-value"><span class="token punctuation attr-equals">=<span class="token punctuation">"{{ + <span class="token punctuation">' <span class="token punctuation">'}}<span class="token punctuation">"<span class="token punctuation">&gt;
{{item}}
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/view<span class="token punctuation">&gt;</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></code></pre>
</div>
<h2>&nbsp;3.3、列表渲染</h2>
<h3 id="wx-for">3.3.1、wx:for</h3>
<p>在组件上使用&nbsp;<code>wx:for</code>&nbsp;控制属性绑定一个数组,即可使用数组中各项的数据重复渲染该组件。</p>
<p>默认数组的当前项的下标变量名默认为&nbsp;<code>index</code>,数组当前项的变量名默认为&nbsp;<code>item</code></p>
<div class="language-html extra-class">
<pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;view <span class="token attr-name"><span class="token namespace">wx:for<span class="token attr-value"><span class="token punctuation attr-equals">=<span class="token punctuation">"{{array}}<span class="token punctuation">"<span class="token punctuation">&gt;
{{index}}: {{item.message}}
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/view<span class="token punctuation">&gt;
</span></span></span></span></span></span></span></span></span></span></span></span></span></span></code></pre>
</div>
<div class="language-js extra-class">
<pre class="language-js"><code><span class="token function">Page<span class="token punctuation">(<span class="token punctuation">{
data<span class="token operator">: <span class="token punctuation">{
    array<span class="token operator">: <span class="token punctuation">[<span class="token punctuation">{
      message<span class="token operator">: <span class="token string">'foo'<span class="token punctuation">,
    <span class="token punctuation">}<span class="token punctuation">, <span class="token punctuation">{
      message<span class="token operator">: <span class="token string">'bar'
    <span class="token punctuation">}<span class="token punctuation">]
<span class="token punctuation">}
<span class="token punctuation">}<span class="token punctuation">)
</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></code></pre>
</div>
<p>使用&nbsp;<code>wx:for-item</code>&nbsp;可以指定数组当前元素的变量名,</p>
<p>使用&nbsp;<code>wx:for-index</code>&nbsp;可以指定数组当前下标的变量名:</p>
<div class="language-html extra-class">
<pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;view <span class="token attr-name"><span class="token namespace">wx:for<span class="token attr-value"><span class="token punctuation attr-equals">=<span class="token punctuation">"{{array}}<span class="token punctuation">" <span class="token attr-name"><span class="token namespace">wx:for-index<span class="token attr-value"><span class="token punctuation attr-equals">=<span class="token punctuation">"idx<span class="token punctuation">" <span class="token attr-name"><span class="token namespace">wx:for-item<span class="token attr-value"><span class="token punctuation attr-equals">=<span class="token punctuation">"itemName<span class="token punctuation">"<span class="token punctuation">&gt;
{{idx}}: {{itemName.message}}
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/view<span class="token punctuation">&gt;
</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></code></pre>
</div>
<p><code>wx:for</code>&nbsp;也可以嵌套,下边是一个九九乘法表</p>
<div class="language-html extra-class">
<pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;view <span class="token attr-name"><span class="token namespace">wx:for<span class="token attr-value"><span class="token punctuation attr-equals">=<span class="token punctuation">"{{}}<span class="token punctuation">" <span class="token attr-name"><span class="token namespace">wx:for-item<span class="token attr-value"><span class="token punctuation attr-equals">=<span class="token punctuation">"i<span class="token punctuation">"<span class="token punctuation">&gt;
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;view <span class="token attr-name"><span class="token namespace">wx:for<span class="token attr-value"><span class="token punctuation attr-equals">=<span class="token punctuation">"{{}}<span class="token punctuation">" <span class="token attr-name"><span class="token namespace">wx:for-item<span class="token attr-value"><span class="token punctuation attr-equals">=<span class="token punctuation">"j<span class="token punctuation">"<span class="token punctuation">&gt;
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;view <span class="token attr-name"><span class="token namespace">wx:if<span class="token attr-value"><span class="token punctuation attr-equals">=<span class="token punctuation">"{{i &lt;= j}}<span class="token punctuation">"<span class="token punctuation">&gt;
      {{i}} * {{j}} = {{i * j}}
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/view<span class="token punctuation">&gt;
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/view<span class="token punctuation">&gt;
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/view<span class="token punctuation">&gt;<br><br></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></code></pre>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">scroll-view </span><span style="color: rgba(255, 0, 0, 1)">scroll-x</span><span style="color: rgba(0, 0, 255, 1)">="true"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">view </span><span style="color: rgba(255, 0, 0, 1)">wx:for</span><span style="color: rgba(0, 0, 255, 1)">="{{}}"</span><span style="color: rgba(255, 0, 0, 1)"> wx:for-item</span><span style="color: rgba(0, 0, 255, 1)">="i"</span><span style="color: rgba(255, 0, 0, 1)"> class</span><span style="color: rgba(0, 0, 255, 1)">="item"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
    <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">view </span><span style="color: rgba(255, 0, 0, 1)">wx:for</span><span style="color: rgba(0, 0, 255, 1)">="{{}}"</span><span style="color: rgba(255, 0, 0, 1)"> wx:for-item</span><span style="color: rgba(0, 0, 255, 1)">="j"</span><span style="color: rgba(255, 0, 0, 1)"> class</span><span style="color: rgba(0, 0, 255, 1)">="exp"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
      <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">text </span><span style="color: rgba(255, 0, 0, 1)">wx:if</span><span style="color: rgba(0, 0, 255, 1)">="{{j&lt;=i}}"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span> {{j}}x{{i}}={{i*j}}<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">text</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
    <span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">scroll-view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span></pre>
</div>
<div class="cnblogs_code">
<pre><span style="color: rgba(128, 0, 0, 1)">.item
</span>{<span style="color: rgba(255, 0, 0, 1)">
display</span>:<span style="color: rgba(0, 0, 255, 1)"> flex</span>;
}<span style="color: rgba(128, 0, 0, 1)">
.exp</span>{<span style="color: rgba(255, 0, 0, 1)">
width</span>:<span style="color: rgba(0, 0, 255, 1)"> 150rpx</span>;
}</pre>
</div>
<p><img src="https://img2023.cnblogs.com/blog/63651/202304/63651-20230425105343636-2044872258.png" alt="" width="948" height="393" loading="lazy"></p>
<p>&nbsp;从小程序基础库版本 2.3.0 开始,在 iPad 上运行的小程序可以支持屏幕旋转。使小程序支持 iPad 屏幕旋转的方法是:在 app.json 中添加 "resizable": true 。</p>
</div>
<h3 id="block-wx-for">3.3.2、block wx:for</h3>
<p>类似&nbsp;<code>block wx:if</code>,也可以将&nbsp;<code>wx:for</code>&nbsp;用在<code>&lt;block/&gt;</code>标签上,以渲染一个包含多节点的结构块。例如:</p>
<div class="language-html extra-class">
<pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;block <span class="token attr-name"><span class="token namespace">wx:for<span class="token attr-value"><span class="token punctuation attr-equals">=<span class="token punctuation">"{{}}<span class="token punctuation">"<span class="token punctuation">&gt;
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;view<span class="token punctuation">&gt; {{index}}: <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/view<span class="token punctuation">&gt;
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;view<span class="token punctuation">&gt; {{item}} <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/view<span class="token punctuation">&gt;
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/block<span class="token punctuation">&gt;
</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></code></pre>
</div>
<h3 id="wx-key">3.3.3、wx:key</h3>
<p>如果列表中项目的位置会动态改变或者有新的项目添加到列表中,并且希望列表中的项目保持自己的特征和状态(如&nbsp;input&nbsp;中的输入内容,switch&nbsp;的选中状态),需要使用&nbsp;<code>wx:key</code>&nbsp;来指定列表中项目的唯一的标识符。</p>
<p><code>wx:key</code>&nbsp;的值以两种形式提供</p>
<ol>
<li>字符串,代表在 for 循环的 array 中 item 的某个 property,该 property 的值需要是列表中唯一的字符串或数字,且不能动态改变。</li>
<li>保留关键字&nbsp;<code>*this</code>&nbsp;代表在 for 循环中的 item 本身,这种表示需要 item 本身是一个唯一的字符串或者数字。</li>
</ol>
<p>当数据改变触发渲染层重新渲染的时候,会校正带有 key 的组件,框架会确保他们被重新排序,而不是重新创建,以确保使组件保持自身的状态,并且提高列表渲染时的效率。</p>
<p><strong>如不提供&nbsp;<code>wx:key</code>,会报一个&nbsp;<code>warning</code>, 如果明确知道该列表是静态,或者不必关注其顺序,可以选择忽略。</strong></p>
<h3 id="示例代码">3.3.4、示例代码</h3>
<p>在开发者工具中预览效果</p>
<div class="language-html extra-class">
<pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;switch <span class="token attr-name"><span class="token namespace">wx:for<span class="token attr-value"><span class="token punctuation attr-equals">=<span class="token punctuation">"{{objectArray}}<span class="token punctuation">" <span class="token attr-name"><span class="token namespace">wx:key<span class="token attr-value"><span class="token punctuation attr-equals">=<span class="token punctuation">"unique<span class="token punctuation">" <span class="token special-attr"><span class="token attr-name">style<span class="token attr-value"><span class="token punctuation attr-equals">=<span class="token punctuation">"<span class="token value css language-css"><span class="token property">display<span class="token punctuation">: block<span class="token punctuation">;<span class="token punctuation">"<span class="token punctuation">&gt; {{item.id}} <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/switch<span class="token punctuation">&gt;
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;button <span class="token attr-name">bindtap<span class="token attr-value"><span class="token punctuation attr-equals">=<span class="token punctuation">"switch<span class="token punctuation">"<span class="token punctuation">&gt; Switch <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/button<span class="token punctuation">&gt;
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;button <span class="token attr-name">bindtap<span class="token attr-value"><span class="token punctuation attr-equals">=<span class="token punctuation">"addToFront<span class="token punctuation">"<span class="token punctuation">&gt; Add to the front <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/button<span class="token punctuation">&gt;

<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;switch <span class="token attr-name"><span class="token namespace">wx:for<span class="token attr-value"><span class="token punctuation attr-equals">=<span class="token punctuation">"{{numberArray}}<span class="token punctuation">" <span class="token attr-name"><span class="token namespace">wx:key<span class="token attr-value"><span class="token punctuation attr-equals">=<span class="token punctuation">"*this<span class="token punctuation">" <span class="token special-attr"><span class="token attr-name">style<span class="token attr-value"><span class="token punctuation attr-equals">=<span class="token punctuation">"<span class="token value css language-css"><span class="token property">display<span class="token punctuation">: block<span class="token punctuation">;<span class="token punctuation">"<span class="token punctuation">&gt; {{item}} <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/switch<span class="token punctuation">&gt;
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;button <span class="token attr-name">bindtap<span class="token attr-value"><span class="token punctuation attr-equals">=<span class="token punctuation">"addNumberToFront<span class="token punctuation">"<span class="token punctuation">&gt; Add to the front <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/button<span class="token punctuation">&gt;
</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></code></pre>
</div>
<div class="language-js extra-class">
<pre class="language-js"><code><span class="token function">Page<span class="token punctuation">(<span class="token punctuation">{
data<span class="token operator">: <span class="token punctuation">{
    objectArray<span class="token operator">: <span class="token punctuation">[
      <span class="token punctuation">{id<span class="token operator">: <span class="token number">5<span class="token punctuation">, unique<span class="token operator">: <span class="token string">'unique_5'<span class="token punctuation">}<span class="token punctuation">,
      <span class="token punctuation">{id<span class="token operator">: <span class="token number">4<span class="token punctuation">, unique<span class="token operator">: <span class="token string">'unique_4'<span class="token punctuation">}<span class="token punctuation">,
      <span class="token punctuation">{id<span class="token operator">: <span class="token number">3<span class="token punctuation">, unique<span class="token operator">: <span class="token string">'unique_3'<span class="token punctuation">}<span class="token punctuation">,
      <span class="token punctuation">{id<span class="token operator">: <span class="token number">2<span class="token punctuation">, unique<span class="token operator">: <span class="token string">'unique_2'<span class="token punctuation">}<span class="token punctuation">,
      <span class="token punctuation">{id<span class="token operator">: <span class="token number">1<span class="token punctuation">, unique<span class="token operator">: <span class="token string">'unique_1'<span class="token punctuation">}<span class="token punctuation">,
      <span class="token punctuation">{id<span class="token operator">: <span class="token number">0<span class="token punctuation">, unique<span class="token operator">: <span class="token string">'unique_0'<span class="token punctuation">}<span class="token punctuation">,
    <span class="token punctuation">]<span class="token punctuation">,
    numberArray<span class="token operator">: <span class="token punctuation">[<span class="token number">1<span class="token punctuation">, <span class="token number">2<span class="token punctuation">, <span class="token number">3<span class="token punctuation">, <span class="token number">4<span class="token punctuation">]
<span class="token punctuation">}<span class="token punctuation">,
<span class="token function-variable function">switch<span class="token operator">: <span class="token keyword">function<span class="token punctuation">(<span class="token parameter">e<span class="token punctuation">) <span class="token punctuation">{
    <span class="token keyword">const length <span class="token operator">= <span class="token keyword">this<span class="token punctuation">.data<span class="token punctuation">.objectArray<span class="token punctuation">.length
    <span class="token keyword">for <span class="token punctuation">(<span class="token keyword">let i <span class="token operator">= <span class="token number">0<span class="token punctuation">; i <span class="token operator">&lt; length<span class="token punctuation">; <span class="token operator">++i<span class="token punctuation">) <span class="token punctuation">{
      <span class="token keyword">const x <span class="token operator">= Math<span class="token punctuation">.<span class="token function">floor<span class="token punctuation">(Math<span class="token punctuation">.<span class="token function">random<span class="token punctuation">(<span class="token punctuation">) <span class="token operator">* length<span class="token punctuation">)
      <span class="token keyword">const y <span class="token operator">= Math<span class="token punctuation">.<span class="token function">floor<span class="token punctuation">(Math<span class="token punctuation">.<span class="token function">random<span class="token punctuation">(<span class="token punctuation">) <span class="token operator">* length<span class="token punctuation">)
      <span class="token keyword">const temp <span class="token operator">= <span class="token keyword">this<span class="token punctuation">.data<span class="token punctuation">.objectArray<span class="token punctuation">
      <span class="token keyword">this<span class="token punctuation">.data<span class="token punctuation">.objectArray<span class="token punctuation"> <span class="token operator">= <span class="token keyword">this<span class="token punctuation">.data<span class="token punctuation">.objectArray<span class="token punctuation">
      <span class="token keyword">this<span class="token punctuation">.data<span class="token punctuation">.objectArray<span class="token punctuation"> <span class="token operator">= temp
    <span class="token punctuation">}
    <span class="token keyword">this<span class="token punctuation">.<span class="token function">setData<span class="token punctuation">(<span class="token punctuation">{
      objectArray<span class="token operator">: <span class="token keyword">this<span class="token punctuation">.data<span class="token punctuation">.objectArray
    <span class="token punctuation">}<span class="token punctuation">)
<span class="token punctuation">}<span class="token punctuation">,
<span class="token function-variable function">addToFront<span class="token operator">: <span class="token keyword">function<span class="token punctuation">(<span class="token parameter">e<span class="token punctuation">) <span class="token punctuation">{
    <span class="token keyword">const length <span class="token operator">= <span class="token keyword">this<span class="token punctuation">.data<span class="token punctuation">.objectArray<span class="token punctuation">.length
    <span class="token keyword">this<span class="token punctuation">.data<span class="token punctuation">.objectArray <span class="token operator">= <span class="token punctuation">[<span class="token punctuation">{id<span class="token operator">: length<span class="token punctuation">, unique<span class="token operator">: <span class="token string">'unique_' <span class="token operator">+ length<span class="token punctuation">}<span class="token punctuation">]<span class="token punctuation">.<span class="token function">concat<span class="token punctuation">(<span class="token keyword">this<span class="token punctuation">.data<span class="token punctuation">.objectArray<span class="token punctuation">)
    <span class="token keyword">this<span class="token punctuation">.<span class="token function">setData<span class="token punctuation">(<span class="token punctuation">{
      objectArray<span class="token operator">: <span class="token keyword">this<span class="token punctuation">.data<span class="token punctuation">.objectArray
    <span class="token punctuation">}<span class="token punctuation">)
<span class="token punctuation">}<span class="token punctuation">,
<span class="token function-variable function">addNumberToFront<span class="token operator">: <span class="token keyword">function<span class="token punctuation">(<span class="token parameter">e<span class="token punctuation">)<span class="token punctuation">{
    <span class="token keyword">this<span class="token punctuation">.data<span class="token punctuation">.numberArray <span class="token operator">= <span class="token punctuation">[ <span class="token keyword">this<span class="token punctuation">.data<span class="token punctuation">.numberArray<span class="token punctuation">.length <span class="token operator">+ <span class="token number">1 <span class="token punctuation">]<span class="token punctuation">.<span class="token function">concat<span class="token punctuation">(<span class="token keyword">this<span class="token punctuation">.data<span class="token punctuation">.numberArray<span class="token punctuation">)
    <span class="token keyword">this<span class="token punctuation">.<span class="token function">setData<span class="token punctuation">(<span class="token punctuation">{
      numberArray<span class="token operator">: <span class="token keyword">this<span class="token punctuation">.data<span class="token punctuation">.numberArray
    <span class="token punctuation">}<span class="token punctuation">)
<span class="token punctuation">}
<span class="token punctuation">}<span class="token punctuation">)<br><br></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></code></pre>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">switch </span><span style="color: rgba(255, 0, 0, 1)">wx:for</span><span style="color: rgba(0, 0, 255, 1)">="{{objectArray}}"</span><span style="color: rgba(255, 0, 0, 1)"> style</span><span style="color: rgba(0, 0, 255, 1)">="display: block;"</span><span style="color: rgba(255, 0, 0, 1)"> wx:key</span><span style="color: rgba(0, 0, 255, 1)">="unique"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>{{item.id}}<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">switch</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">button </span><span style="color: rgba(255, 0, 0, 1)">bindtap</span><span style="color: rgba(0, 0, 255, 1)">="switchHandle"</span><span style="color: rgba(255, 0, 0, 1)"> type</span><span style="color: rgba(0, 0, 255, 1)">="primary"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>切换<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">button</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">button </span><span style="color: rgba(255, 0, 0, 1)">bindtap</span><span style="color: rgba(0, 0, 255, 1)">="addToFront"</span><span style="color: rgba(255, 0, 0, 1)"> type</span><span style="color: rgba(0, 0, 255, 1)">="primary"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>在最前面添加对象<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">button</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">switch </span><span style="color: rgba(255, 0, 0, 1)">wx:for</span><span style="color: rgba(0, 0, 255, 1)">="{{numberArray}}"</span><span style="color: rgba(255, 0, 0, 1)"> wx:key</span><span style="color: rgba(0, 0, 255, 1)">="*this"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>{{item}}<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">switch</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">button </span><span style="color: rgba(255, 0, 0, 1)">bindtap</span><span style="color: rgba(0, 0, 255, 1)">="addNumberToFront"</span><span style="color: rgba(255, 0, 0, 1)"> type</span><span style="color: rgba(0, 0, 255, 1)">="primary"</span> <span style="color: rgba(0, 0, 255, 1)">&gt;</span>在最前面添加数字<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">button</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span></pre>
</div>
<div class="cnblogs_code">
<pre>const page=<span style="color: rgba(0, 0, 0, 1)">{
data:{
    objectArray:[
      {id:</span>5,unique:"unique_5"<span style="color: rgba(0, 0, 0, 1)">},
      {id:</span>4,unique:"unique_4"<span style="color: rgba(0, 0, 0, 1)">},
      {id:</span>3,unique:"unique_3"<span style="color: rgba(0, 0, 0, 1)">},
      {id:</span>2,unique:"unique_2"<span style="color: rgba(0, 0, 0, 1)">},
      {id:</span>1,unique:"unique_1"<span style="color: rgba(0, 0, 0, 1)">},
      {id:</span>0,unique:"unique_0"<span style="color: rgba(0, 0, 0, 1)">}
    ],
    numberArray:[</span>3,2,1<span style="color: rgba(0, 0, 0, 1)">]
},
switchHandle(e){
    let length</span>=<span style="color: rgba(0, 0, 255, 1)">this</span><span style="color: rgba(0, 0, 0, 1)">.data.objectArray.length;
    </span><span style="color: rgba(0, 0, 255, 1)">for</span>(let i=0;i&lt;length;i++<span style="color: rgba(0, 0, 0, 1)">){
      let x</span>=Math.floor(Math.random()*<span style="color: rgba(0, 0, 0, 1)">length);
      let y</span>=Math.floor(Math.random()*<span style="color: rgba(0, 0, 0, 1)">length);
      let temp</span>=<span style="color: rgba(0, 0, 255, 1)">this</span><span style="color: rgba(0, 0, 0, 1)">.data.objectArray;
      </span><span style="color: rgba(0, 0, 255, 1)">this</span>.data.objectArray=<span style="color: rgba(0, 0, 255, 1)">this</span><span style="color: rgba(0, 0, 0, 1)">.data.objectArray;
      </span><span style="color: rgba(0, 0, 255, 1)">this</span>.data.objectArray=<span style="color: rgba(0, 0, 0, 1)">temp;
    }
    </span><span style="color: rgba(0, 0, 255, 1)">this</span>.setData({objectArray:<span style="color: rgba(0, 0, 255, 1)">this</span><span style="color: rgba(0, 0, 0, 1)">.data.objectArray});
},
addToFront(e){
    let length</span>=<span style="color: rgba(0, 0, 255, 1)">this</span><span style="color: rgba(0, 0, 0, 1)">.data.objectArray.length;
    </span><span style="color: rgba(0, 0, 255, 1)">this</span>.data.objectArray=[{id:length,unique:"unique_"+length}].concat(<span style="color: rgba(0, 0, 255, 1)">this</span><span style="color: rgba(0, 0, 0, 1)">.data.objectArray);
    </span><span style="color: rgba(0, 0, 255, 1)">this</span>.setData({objectArray:<span style="color: rgba(0, 0, 255, 1)">this</span><span style="color: rgba(0, 0, 0, 1)">.data.objectArray});
},
addNumberToFront(e){
    let length</span>=<span style="color: rgba(0, 0, 255, 1)">this</span><span style="color: rgba(0, 0, 0, 1)">.data.numberArray.length;
    </span><span style="color: rgba(0, 0, 255, 1)">this</span>.data.numberArray=.concat(<span style="color: rgba(0, 0, 255, 1)">this</span><span style="color: rgba(0, 0, 0, 1)">.data.numberArray);
    </span><span style="color: rgba(0, 0, 255, 1)">this</span>.setData({numberArray:<span style="color: rgba(0, 0, 255, 1)">this</span><span style="color: rgba(0, 0, 0, 1)">.data.numberArray});
}
};

Page(page)</span></pre>
</div>
<p><img src="https://img2023.cnblogs.com/blog/63651/202304/63651-20230421114853323-911867264.png" alt="" loading="lazy"></p>
</div>
<h3 id="注意事项">3.3.5、注意事项</h3>
<p>当&nbsp;<code>wx:for</code>&nbsp;的值为字符串时,会将字符串解析成字符串数组</p>
<div class="language-html extra-class">
<pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;view <span class="token attr-name"><span class="token namespace">wx:for<span class="token attr-value"><span class="token punctuation attr-equals">=<span class="token punctuation">"array<span class="token punctuation">"<span class="token punctuation">&gt;
{{item}}
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/view<span class="token punctuation">&gt;
</span></span></span></span></span></span></span></span></span></span></span></span></span></span></code></pre>
</div>
<p>等同于</p>
<div class="language-html extra-class">
<pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;view <span class="token attr-name"><span class="token namespace">wx:for<span class="token attr-value"><span class="token punctuation attr-equals">=<span class="token punctuation">"{{[<span class="token punctuation">'a<span class="token punctuation">',<span class="token punctuation">'r<span class="token punctuation">',<span class="token punctuation">'r<span class="token punctuation">',<span class="token punctuation">'a<span class="token punctuation">',<span class="token punctuation">'y<span class="token punctuation">']}}<span class="token punctuation">"<span class="token punctuation">&gt;
{{item}}
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/view<span class="token punctuation">&gt;
</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></code></pre>
</div>
<p><strong>注意:</strong>&nbsp;花括号和引号之间如果有空格,将最终被解析成为字符串</p>
<div class="language-html extra-class">
<pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;view <span class="token attr-name"><span class="token namespace">wx:for<span class="token attr-value"><span class="token punctuation attr-equals">=<span class="token punctuation">"{{}} <span class="token punctuation">"<span class="token punctuation">&gt;
{{item}}
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/view<span class="token punctuation">&gt;
</span></span></span></span></span></span></span></span></span></span></span></span></span></span></code></pre>
</div>
<p>等同于</p>
<div class="language-html extra-class">
<pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;view <span class="token attr-name"><span class="token namespace">wx:for<span class="token attr-value"><span class="token punctuation attr-equals">=<span class="token punctuation">"{{ + <span class="token punctuation">' <span class="token punctuation">'}}<span class="token punctuation">" <span class="token punctuation">&gt;
{{item}}
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/view<span class="token punctuation">&gt;</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></code></pre>
</div>
<h2>&nbsp;3.4、条件渲染</h2>
<h3 id="wx-if">3.4.1、wx:if</h3>
<p>在框架中,使用&nbsp;<code>wx:if=""</code>&nbsp;来判断是否需要渲染该代码块:</p>
<div class="language-html extra-class">
<pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;view <span class="token attr-name"><span class="token namespace">wx:if<span class="token attr-value"><span class="token punctuation attr-equals">=<span class="token punctuation">"{{condition}}<span class="token punctuation">"<span class="token punctuation">&gt; True <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/view<span class="token punctuation">&gt;
</span></span></span></span></span></span></span></span></span></span></span></span></span></span></code></pre>
</div>
<p>也可以用&nbsp;<code>wx:elif</code>&nbsp;和&nbsp;<code>wx:else</code>&nbsp;来添加一个 else 块:</p>
<div class="language-html extra-class">
<pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;view <span class="token attr-name"><span class="token namespace">wx:if<span class="token attr-value"><span class="token punctuation attr-equals">=<span class="token punctuation">"{{length &gt; 5}}<span class="token punctuation">"<span class="token punctuation">&gt; 1 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/view<span class="token punctuation">&gt;
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;view <span class="token attr-name"><span class="token namespace">wx:elif<span class="token attr-value"><span class="token punctuation attr-equals">=<span class="token punctuation">"{{length &gt; 2}}<span class="token punctuation">"<span class="token punctuation">&gt; 2 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/view<span class="token punctuation">&gt;
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;view <span class="token attr-name"><span class="token namespace">wx:else<span class="token punctuation">&gt; 3 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/view<span class="token punctuation">&gt;<br></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></code></pre>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span><span style="color: rgba(0, 0, 0, 1)">
成绩:</span><span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">input </span><span style="color: rgba(255, 0, 0, 1)">value</span><span style="color: rgba(0, 0, 255, 1)">="{{mark}}"</span><span style="color: rgba(255, 0, 0, 1)"> bindinput</span><span style="color: rgba(0, 0, 255, 1)">="inputHandle"</span><span style="color: rgba(0, 0, 255, 1)">/&gt;</span><span style="color: rgba(0, 0, 0, 1)">
成绩是:{{mark}}
</span><span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span><span style="color: rgba(0, 0, 0, 1)">
等级是:
</span><span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">text </span><span style="color: rgba(255, 0, 0, 1)">wx:if</span><span style="color: rgba(0, 0, 255, 1)">="{{mark&gt;=90}}"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>优秀<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">text</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">text </span><span style="color: rgba(255, 0, 0, 1)">wx:elif</span><span style="color: rgba(0, 0, 255, 1)">="{{mark&lt;90 &amp;&amp; mark&gt;=75}}"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>良好<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">text</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">text </span><span style="color: rgba(255, 0, 0, 1)">wx:elif</span><span style="color: rgba(0, 0, 255, 1)">="{{mark&lt;75 &amp;&amp; mark&gt;=60}}"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>及格<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">text</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">text </span><span style="color: rgba(255, 0, 0, 1)">wx:else</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>不及格<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">text</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span></pre>
</div>
<div class="cnblogs_code">
<pre>const page=<span style="color: rgba(0, 0, 0, 1)">{
data:{
    users:[{id:</span>1001,name:"jack",age:18<span style="color: rgba(0, 0, 0, 1)">},
    {id:</span>1002,name:"mark",age:17<span style="color: rgba(0, 0, 0, 1)">},
    {id:</span>1003,name:"rose",age:20<span style="color: rgba(0, 0, 0, 1)">},
    {id:</span>1004,name:"lili",age:15<span style="color: rgba(0, 0, 0, 1)">},
    {id:</span>1005,name:"lucy",age:22<span style="color: rgba(0, 0, 0, 1)">}],
    isShow:</span><span style="color: rgba(0, 0, 255, 1)">true</span><span style="color: rgba(0, 0, 0, 1)">,
    array1:[</span>1,2,3,4,5,6,7,8,9<span style="color: rgba(0, 0, 0, 1)">],
    mark:</span>0<span style="color: rgba(0, 0, 0, 1)">
},
tapHandle(e){
    </span><span style="color: rgba(0, 0, 255, 1)">this</span>.setData({isShow:!<span style="color: rgba(0, 0, 255, 1)">this</span><span style="color: rgba(0, 0, 0, 1)">.data.isShow});
},
inputHandle(e){
    </span><span style="color: rgba(0, 0, 255, 1)">this</span><span style="color: rgba(0, 0, 0, 1)">.setData({mark:e.detail.value})
}
};

Page(page);</span></pre>
</div>
<p><img src="https://img2023.cnblogs.com/blog/63651/202304/63651-20230426095341103-1376887805.png" alt="" loading="lazy"></p>
</div>
<h3 id="block-wx-if">3.4.2、block wx:if</h3>
<p>因为&nbsp;<code>wx:if</code>&nbsp;是一个控制属性,需要将它添加到一个标签上。如果要一次性判断多个组件标签,可以使用一个&nbsp;<code>&lt;block/&gt;</code>&nbsp;标签将多个组件包装起来,并在上边使用&nbsp;<code>wx:if</code>&nbsp;控制属性。</p>
<div class="language-html extra-class">
<pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;block <span class="token attr-name"><span class="token namespace">wx:if<span class="token attr-value"><span class="token punctuation attr-equals">=<span class="token punctuation">"{{true}}<span class="token punctuation">"<span class="token punctuation">&gt;
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;view<span class="token punctuation">&gt; view1 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/view<span class="token punctuation">&gt;
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;view<span class="token punctuation">&gt; view2 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/view<span class="token punctuation">&gt;
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/block<span class="token punctuation">&gt;
</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></code></pre>
</div>
<p><strong>注意:</strong>&nbsp;<code>&lt;block/&gt;</code>&nbsp;并不是一个组件,它仅仅是一个包装元素,不会在页面中做任何渲染,只接受控制属性。</p>
<h3><strong><code>3.4.3、wx:if</code>&nbsp;vs&nbsp;<code>hidden</code></strong></h3>
<p>因为&nbsp;<code>wx:if</code>&nbsp;之中的模板也可能包含数据绑定,所以当&nbsp;<code>wx:if</code>&nbsp;的条件值切换时,框架有一个局部渲染的过程,因为它会确保条件块在切换时销毁或重新渲染。</p>
<p>同时&nbsp;<code>wx:if</code>&nbsp;也是<strong>惰性的</strong>,如果在初始渲染条件为&nbsp;<code>false</code>,框架什么也不做,在条件第一次变成真的时候才开始局部渲染。</p>
<p>相比之下,<code>hidden</code>&nbsp;就简单的多,组件始终会被渲染,只是简单的控制显示与隐藏。</p>
<p>一般来说,<code>wx:if</code>&nbsp;有更高的切换消耗而&nbsp;<code>hidden</code>&nbsp;有更高的初始渲染消耗。因此,如果需要频繁切换的情景下,用&nbsp;<code>hidden</code>&nbsp;更好,如果在运行时条件不大可能改变则&nbsp;<code>wx:if</code>&nbsp;较好。</p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">view </span><span style="color: rgba(255, 0, 0, 1)">wx:if</span><span style="color: rgba(0, 0, 255, 1)">="{{isShow}}"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span><span style="color: rgba(0, 0, 0, 1)">
你可以看到我wx:if
</span><span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">view </span><span style="color: rgba(255, 0, 0, 1)">hidden</span><span style="color: rgba(0, 0, 255, 1)">="{{!isShow}}"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span><span style="color: rgba(0, 0, 0, 1)">
你可以看到我hidden
</span><span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">button </span><span style="color: rgba(255, 0, 0, 1)">bindtap</span><span style="color: rgba(0, 0, 255, 1)">="toggleIsShow"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>切换isShow的值={{isShow}}<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">button</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span></pre>
</div>
<div class="cnblogs_code">
<pre>const page=<span style="color: rgba(0, 0, 0, 1)">{
data:{
    isShow:</span><span style="color: rgba(0, 0, 255, 1)">true</span><span style="color: rgba(0, 0, 0, 1)">
},
toggleIsShow(e){
    </span><span style="color: rgba(0, 0, 255, 1)">this</span>.setData({isShow:!<span style="color: rgba(0, 0, 255, 1)">this</span><span style="color: rgba(0, 0, 0, 1)">.data.isShow})
}
};

Page(page)</span></pre>
</div>
<p><img src="https://img2023.cnblogs.com/blog/63651/202304/63651-20230421135708331-1134739716.png" alt="" width="363" height="633" loading="lazy"></p>
<h2>&nbsp;3.5、模板</h2>
<p>WXML提供模板(template),可以在模板中定义代码片段,然后在不同的地方调用。</p>
<h3 id="定义模板">3.5.1、定义模板</h3>
<p>使用 name 属性,作为模板的名字。然后在<code>&lt;template/&gt;</code>内定义代码片段,如:</p>
<div class="language-html extra-class">
<pre class="language-html"><code><span class="token comment">&lt;!--
index: int
msg: string
time: string
--&gt;
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;template <span class="token attr-name">name<span class="token attr-value"><span class="token punctuation attr-equals">=<span class="token punctuation">"msgItem<span class="token punctuation">"<span class="token punctuation">&gt;
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;view<span class="token punctuation">&gt;
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;text<span class="token punctuation">&gt; {{index}}: {{msg}} <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/text<span class="token punctuation">&gt;
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;text<span class="token punctuation">&gt; Time: {{time}} <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/text<span class="token punctuation">&gt;
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/view<span class="token punctuation">&gt;
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/template<span class="token punctuation">&gt;<br><br></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></code></pre>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">template </span><span style="color: rgba(255, 0, 0, 1)">name</span><span style="color: rgba(0, 0, 255, 1)">="card"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">view </span><span style="color: rgba(255, 0, 0, 1)">class</span><span style="color: rgba(0, 0, 255, 1)">="card"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
    <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>编号:{{id}}<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
    <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>姓名:{{name}}<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
    <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>年龄:{{age}}<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">template</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>

<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">template </span><span style="color: rgba(255, 0, 0, 1)">is</span><span style="color: rgba(0, 0, 255, 1)">="card"</span><span style="color: rgba(255, 0, 0, 1)"> data</span><span style="color: rgba(0, 0, 255, 1)">="{{id:1006,name:'张三',age:88}}"</span><span style="color: rgba(0, 0, 255, 1)">&gt;&lt;/</span><span style="color: rgba(128, 0, 0, 1)">template</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">template </span><span style="color: rgba(255, 0, 0, 1)">is</span><span style="color: rgba(0, 0, 255, 1)">="card"</span><span style="color: rgba(255, 0, 0, 1)"> data</span><span style="color: rgba(0, 0, 255, 1)">="{{...user1}}"</span><span style="color: rgba(0, 0, 255, 1)">&gt;&lt;/</span><span style="color: rgba(128, 0, 0, 1)">template</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span></pre>
</div>
<div class="cnblogs_code">
<pre>const page=<span style="color: rgba(0, 0, 0, 1)">{
data:{
    users:[{id:</span>1001,name:"jack",age:18<span style="color: rgba(0, 0, 0, 1)">},
    {id:</span>1002,name:"mark",age:17<span style="color: rgba(0, 0, 0, 1)">},
    {id:</span>1003,name:"rose",age:20<span style="color: rgba(0, 0, 0, 1)">},
    {id:</span>1004,name:"lili",age:15<span style="color: rgba(0, 0, 0, 1)">},
    {id:</span>1005,name:"lucy",age:22<span style="color: rgba(0, 0, 0, 1)">}],
    isShow:</span><span style="color: rgba(0, 0, 255, 1)">true</span><span style="color: rgba(0, 0, 0, 1)">,
    array1:[</span>1,2,3,4,5,6,7,8,9<span style="color: rgba(0, 0, 0, 1)">],
    user1:{id:</span>1007,name:'李四',age:18<span style="color: rgba(0, 0, 0, 1)">}
},
tapHandle(e){
    </span><span style="color: rgba(0, 0, 255, 1)">this</span>.setData({isShow:!<span style="color: rgba(0, 0, 255, 1)">this</span><span style="color: rgba(0, 0, 0, 1)">.data.isShow});
},
};

Page(page);</span></pre>
</div>
<p><img src="https://img2023.cnblogs.com/blog/63651/202304/63651-20230426100905397-1803738299.png" alt="" loading="lazy"></p>
</div>
<h3 id="使用模板">3.5.2、使用模板</h3>
<p>使用 is 属性,声明需要的使用的模板,然后将模板所需要的 data 传入,如:</p>
<div class="language-html extra-class">
<pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;template <span class="token attr-name">is<span class="token attr-value"><span class="token punctuation attr-equals">=<span class="token punctuation">"msgItem<span class="token punctuation">" <span class="token attr-name">data<span class="token attr-value"><span class="token punctuation attr-equals">=<span class="token punctuation">"{{...item}}<span class="token punctuation">"<span class="token punctuation">/&gt;
</span></span></span></span></span></span></span></span></span></span></span></span></span></span></code></pre>
</div>
<div class="language-js extra-class">
<pre class="language-js"><code><span class="token function">Page<span class="token punctuation">(<span class="token punctuation">{
data<span class="token operator">: <span class="token punctuation">{
    item<span class="token operator">: <span class="token punctuation">{
      index<span class="token operator">: <span class="token number">0<span class="token punctuation">,
      msg<span class="token operator">: <span class="token string">'this is a template'<span class="token punctuation">,
      time<span class="token operator">: <span class="token string">'2016-09-15'
    <span class="token punctuation">}
<span class="token punctuation">}
<span class="token punctuation">}<span class="token punctuation">)
</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></code></pre>
</div>
<p>is 属性可以使用 Mustache 语法,来动态决定具体需要渲染哪个模板:</p>
<div class="language-html extra-class">
<pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;template <span class="token attr-name">name<span class="token attr-value"><span class="token punctuation attr-equals">=<span class="token punctuation">"odd<span class="token punctuation">"<span class="token punctuation">&gt;
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;view<span class="token punctuation">&gt; odd <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/view<span class="token punctuation">&gt;
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/template<span class="token punctuation">&gt;
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;template <span class="token attr-name">name<span class="token attr-value"><span class="token punctuation attr-equals">=<span class="token punctuation">"even<span class="token punctuation">"<span class="token punctuation">&gt;
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;view<span class="token punctuation">&gt; even <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/view<span class="token punctuation">&gt;
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/template<span class="token punctuation">&gt;

<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;block <span class="token attr-name"><span class="token namespace">wx:for<span class="token attr-value"><span class="token punctuation attr-equals">=<span class="token punctuation">"{{}}<span class="token punctuation">"<span class="token punctuation">&gt;
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;template <span class="token attr-name">is<span class="token attr-value"><span class="token punctuation attr-equals">=<span class="token punctuation">"{{item % 2 == 0 ? <span class="token punctuation">'even<span class="token punctuation">' : <span class="token punctuation">'odd<span class="token punctuation">'}}<span class="token punctuation">"<span class="token punctuation">/&gt;
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/block<span class="token punctuation">&gt;<br></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></code></pre>
<div class="cnblogs_code">
<pre>const page=<span style="color: rgba(0, 0, 0, 1)">{
data:{
    users:[{id:</span>1001,name:"jack",age:18<span style="color: rgba(0, 0, 0, 1)">},
    {id:</span>1002,name:"mark",age:17<span style="color: rgba(0, 0, 0, 1)">},
    {id:</span>1003,name:"rose",age:20<span style="color: rgba(0, 0, 0, 1)">},
    {id:</span>1004,name:"lili",age:15<span style="color: rgba(0, 0, 0, 1)">},
    {id:</span>1005,name:"lucy",age:22<span style="color: rgba(0, 0, 0, 1)">}]
}
};
Page(page);</span></pre>
</div>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">template </span><span style="color: rgba(255, 0, 0, 1)">name</span><span style="color: rgba(0, 0, 255, 1)">="cardA"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">view </span><span style="color: rgba(255, 0, 0, 1)">class</span><span style="color: rgba(0, 0, 255, 1)">="card"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
    <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>编号:{{id}}<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
    <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>姓名:{{name}}<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
    <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>年龄:{{age}}<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">template</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>

<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">template </span><span style="color: rgba(255, 0, 0, 1)">name</span><span style="color: rgba(0, 0, 255, 1)">="cardB"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">view </span><span style="color: rgba(255, 0, 0, 1)">class</span><span style="color: rgba(0, 0, 255, 1)">="card bgGreen"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
    <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">text</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>编号:{{id}}<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">text</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
    <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">text</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>姓名:{{name}}<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">text</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
    <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">text</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>年龄:{{age}}<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">text</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">template</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>

<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">view </span><span style="color: rgba(255, 0, 0, 1)">wx:for</span><span style="color: rgba(0, 0, 255, 1)">="{{users}}"</span><span style="color: rgba(255, 0, 0, 1)"> wx:key</span><span style="color: rgba(0, 0, 255, 1)">="id"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">template </span><span style="color: rgba(255, 0, 0, 1)">is</span><span style="color: rgba(0, 0, 255, 1)">="{{index%2===1?'cardA':'cardB'}}"</span><span style="color: rgba(255, 0, 0, 1)"> data</span><span style="color: rgba(0, 0, 255, 1)">="{{...item}}"</span><span style="color: rgba(0, 0, 255, 1)">&gt;&lt;/</span><span style="color: rgba(128, 0, 0, 1)">template</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">view</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span></pre>
</div>
<div class="cnblogs_code">
<pre><span style="color: rgba(128, 0, 0, 1)">view</span>{<span style="color: rgba(255, 0, 0, 1)">
margin</span>:<span style="color: rgba(0, 0, 255, 1)"> 10rpx</span>;
}<span style="color: rgba(128, 0, 0, 1)">
.card</span>{<span style="color: rgba(255, 0, 0, 1)">
background</span>:<span style="color: rgba(0, 0, 255, 1)"> oldlace</span>;<span style="color: rgba(255, 0, 0, 1)">
border-radius</span>:<span style="color: rgba(0, 0, 255, 1)"> 20rpx</span>;<span style="color: rgba(255, 0, 0, 1)">
padding</span>:<span style="color: rgba(0, 0, 255, 1)"> 16rpx</span>;<span style="color: rgba(255, 0, 0, 1)">
border</span>:<span style="color: rgba(0, 0, 255, 1)"> 2px solid orangered</span>;
}<span style="color: rgba(128, 0, 0, 1)">
.bgGreen</span>{<span style="color: rgba(255, 0, 0, 1)">
background</span>:<span style="color: rgba(0, 0, 255, 1)"> lightgreen</span>;
}</pre>
</div>
<p><img src="https://img2023.cnblogs.com/blog/63651/202304/63651-20230426103844572-478387129.png" alt="" loading="lazy"></p>
</div>
<h3 id="模板的作用域">3.5.3、模板的作用域</h3>
<p>模板拥有自己的作用域,只能使用 data 传入的数据以及模板定义文件中定义的&nbsp;<code>&lt;wxs /&gt;</code>&nbsp;模块。</p>
<h2>&nbsp;3.6、引用</h2>
<p>WXML 提供两种文件引用方式<code>import</code>和<code>include</code>。</p>
<h3 id="import">3.6.1、import</h3>
<p><code>import</code>可以在该文件中使用目标文件定义的<code>template</code>,如:</p>
<p>在 item.wxml 中定义了一个叫<code>item</code>的<code>template</code>:</p>
<div class="language-html extra-class">
<pre class="language-html"><code><span class="token comment">&lt;!-- item.wxml --&gt;
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;template <span class="token attr-name">name<span class="token attr-value"><span class="token punctuation attr-equals">=<span class="token punctuation">"item<span class="token punctuation">"<span class="token punctuation">&gt;
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;text<span class="token punctuation">&gt;{{text}}<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/text<span class="token punctuation">&gt;
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/template<span class="token punctuation">&gt;
</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></code></pre>
</div>
<p>在 index.wxml 中引用了 item.wxml,就可以使用<code>item</code>模板:</p>
<div class="language-html extra-class">
<pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;import <span class="token attr-name">src<span class="token attr-value"><span class="token punctuation attr-equals">=<span class="token punctuation">"item.wxml<span class="token punctuation">"<span class="token punctuation">/&gt;
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;template <span class="token attr-name">is<span class="token attr-value"><span class="token punctuation attr-equals">=<span class="token punctuation">"item<span class="token punctuation">" <span class="token attr-name">data<span class="token attr-value"><span class="token punctuation attr-equals">=<span class="token punctuation">"{{text: <span class="token punctuation">'forbar<span class="token punctuation">'}}<span class="token punctuation">"<span class="token punctuation">/&gt;
</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></code></pre>
</div>
<h3 id="import-的作用域">3.6.2、import 的作用域</h3>
<p>import 有作用域的概念,即只会 import 目标文件中定义的 template,而不会 import 目标文件 import 的 template。</p>
<p><strong>如:C import B,B import A,在C中可以使用B定义的<code>template</code>,在B中可以使用A定义的<code>template</code>,但是C不能使用A定义的<code>template</code></strong>。</p>
<div class="language-html extra-class">
<pre class="language-html"><code><span class="token comment">&lt;!-- A.wxml --&gt;
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;template <span class="token attr-name">name<span class="token attr-value"><span class="token punctuation attr-equals">=<span class="token punctuation">"A<span class="token punctuation">"<span class="token punctuation">&gt;
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;text<span class="token punctuation">&gt; A template <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/text<span class="token punctuation">&gt;
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/template<span class="token punctuation">&gt;
</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></code></pre>
</div>
<div class="language-html extra-class">
<pre class="language-html"><code><span class="token comment">&lt;!-- B.wxml --&gt;
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;import <span class="token attr-name">src<span class="token attr-value"><span class="token punctuation attr-equals">=<span class="token punctuation">"a.wxml<span class="token punctuation">"<span class="token punctuation">/&gt;
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;template <span class="token attr-name">name<span class="token attr-value"><span class="token punctuation attr-equals">=<span class="token punctuation">"B<span class="token punctuation">"<span class="token punctuation">&gt;
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;text<span class="token punctuation">&gt; B template <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/text<span class="token punctuation">&gt;
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/template<span class="token punctuation">&gt;
</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></code></pre>
</div>
<div class="language-html extra-class">
<pre class="language-html"><code><span class="token comment">&lt;!-- C.wxml --&gt;
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;import <span class="token attr-name">src<span class="token attr-value"><span class="token punctuation attr-equals">=<span class="token punctuation">"b.wxml<span class="token punctuation">"<span class="token punctuation">/&gt;
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;template <span class="token attr-name">is<span class="token attr-value"><span class="token punctuation attr-equals">=<span class="token punctuation">"A<span class="token punctuation">"<span class="token punctuation">/&gt;<span class="token comment">&lt;!-- Error! Can not use tempalte when not import A. --&gt;
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;template <span class="token attr-name">is<span class="token attr-value"><span class="token punctuation attr-equals">=<span class="token punctuation">"B<span class="token punctuation">"<span class="token punctuation">/&gt;
</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></code></pre>
</div>
<h3 id="include">3.6.3、include</h3>
<p><code>include</code>&nbsp;可以将目标文件<strong>除了</strong>&nbsp;<code>&lt;template/&gt;</code>&nbsp;<code>&lt;wxs/&gt;</code>&nbsp;外的整个代码引入,相当于是拷贝到&nbsp;<code>include</code>&nbsp;位置,如:</p>
<div class="language-html extra-class">
<pre class="language-html"><code><span class="token comment">&lt;!-- index.wxml --&gt;
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;include <span class="token attr-name">src<span class="token attr-value"><span class="token punctuation attr-equals">=<span class="token punctuation">"header.wxml<span class="token punctuation">"<span class="token punctuation">/&gt;
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;view<span class="token punctuation">&gt; body <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/view<span class="token punctuation">&gt;
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;include <span class="token attr-name">src<span class="token attr-value"><span class="token punctuation attr-equals">=<span class="token punctuation">"footer.wxml<span class="token punctuation">"<span class="token punctuation">/&gt;
</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></code></pre>
</div>
<div class="language-html extra-class">
<pre class="language-html"><code><span class="token comment">&lt;!-- header.wxml --&gt;
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;view<span class="token punctuation">&gt; header <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/view<span class="token punctuation">&gt;
</span></span></span></span></span></span></span></span></span></code></pre>
</div>
<div class="language-html extra-class">
<pre class="language-html"><code><span class="token comment">&lt;!-- footer.wxml --&gt;
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;view<span class="token punctuation">&gt; footer <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/view<span class="token punctuation">&gt;</span></span></span></span></span></span></span></span></span></code></pre>
</div>
<p>&nbsp;</p>
<p><span style="font-size: 14pt"><strong>五、uni-app</strong></span></p>
<p><span style="font-size: 14pt"><strong>5.1:什么是uni-app</strong></span></p>
<p><span style="font-size: 15px">uni-app 是一个使用 Vue.js&nbsp;开发所有前端应用的框架,开发者编写一套代码,可发布到iOS、Android、Web(响应式)、以及各种小程序(微信/支付宝/百度/头条/飞书/QQ/快手/钉钉/淘宝)、快应用等多个平台。</span></p>
<p><span style="font-size: 15px">官方文档:https://uniapp.dcloud.net.cn/</span></p>
<p><span style="font-size: 15px"><img src="https://img2023.cnblogs.com/blog/2401301/202301/2401301-20230103232149856-1383383051.webp" alt="" width="268" height="224" loading="lazy"></span></p>
<p><strong><span style="font-size: 14pt">5.2:uni-app的特点</span></strong></p>
<p><strong><span style="font-size: 14pt">优点</span></strong></p>
<p><span style="font-size: 15px">1、跨平台发行,运行体验更好</span><br><span style="font-size: 15px">2、与小程序的组件、API一致;</span><br><span style="font-size: 15px">3、兼容weex原生渲染,增加了开发效率高,但是由于weex坑比较多,建议还是使用局部渲染优化;</span><br><span style="font-size: 15px">4、通用前端技术栈,学习成本更低</span><br><span style="font-size: 15px">5、支持vue语法,微信小程序API</span><br><span style="font-size: 15px">6、内嵌mpvue</span><br><span style="font-size: 15px">7、开发生态,组件更丰富</span><br><span style="font-size: 15px">8、支持通过npm安装第三方包</span><br><span style="font-size: 15px">9、支持微信小程序自定义组件及JS SDK</span><br><span style="font-size: 15px">10、兼容mpvue组件及项目(内嵌mpvue开源框架)</span><br><span style="font-size: 15px">11、App端支持和原生混合编码</span><br><span style="font-size: 15px">12、插件丰富,DCloud将发布插件到市场</span></p>
<p><span style="font-size: 14pt"><strong>缺点</strong></span></p>
<p><span style="font-size: 15px">1.、兼容性不够好:uni-app 对于不同平台的兼容性不够好,有些功能在不同平台上可能会有差异。</span></p>
<p><span style="font-size: 15px">2.、文档不够完善:uni-app 的文档不够完善,有些功能的使用方法不够清晰,需要开发者自己去摸索。</span></p>
<p><span style="font-size: 14pt"><strong>5.3:创建uni-app</strong></span></p>
<p><span style="font-size: 15px">一、开始之前,开发者需先下载安装如下工具:HBuilderX</span></p>
<p><span style="font-size: 15px">官网下载地址:https://www.dcloud.io/hbuilderx.html</span></p>
<p><img src="https://img2023.cnblogs.com/blog/2401301/202301/2401301-20230130193728148-1438568580.png" alt="" loading="lazy"></p>
<p><span style="font-size: 15px">二、打开HbuilderX,在点击工具栏里的文件 -&gt; 新建 -&gt; 项目</span></p>
<p><img src="https://img2023.cnblogs.com/blog/2401301/202301/2401301-20230130193951179-979906709.png" alt="" width="580" height="328" loading="lazy"></p>
<p><span style="font-size: 15px">三、选择<code>uni-app</code>类型,输入工程名,选择模板,点击创建,即可成功创建。</span></p>
<p><img src="https://img2023.cnblogs.com/blog/2401301/202301/2401301-20230130200232814-1757645204.png" alt="" width="830" height="689" loading="lazy"></p>
<p><span style="font-size: 15px">四:配置uni-app的相关路径以及微信小程序的AppID</span></p>
<p><span style="font-size: 15px">配置路径</span></p>
<p><img src="https://img2023.cnblogs.com/blog/2401301/202301/2401301-20230130194818159-231979702.png" alt="" width="395" height="263" loading="lazy">&nbsp;<img src="https://img2023.cnblogs.com/blog/2401301/202301/2401301-20230130194857758-515019875.png" alt="" width="632" height="261" loading="lazy"></p>
<p><span style="font-size: 15px">配置AppID</span></p>
<p><img src="https://img2023.cnblogs.com/blog/2401301/202301/2401301-20230130194945714-197467217.png" alt="" width="245" height="401" loading="lazy">&nbsp;<img src="https://img2023.cnblogs.com/blog/2401301/202301/2401301-20230130195056791-2144298277.png" alt="" width="746" height="400" loading="lazy"></p>
<p><span style="font-size: 15px">五、一切准备就绪后,我们就可以在HBuilderX中启动我们的微信小程序了</span></p>
<p><img src="https://img2023.cnblogs.com/blog/2401301/202301/2401301-20230130195505709-1896648042.png" alt="" width="451" height="353" loading="lazy"><img src="https://img2023.cnblogs.com/blog/2401301/202301/2401301-20230130195804934-605415936.png" alt="" width="605" height="354" loading="lazy"></p>
<p><span style="font-size: 16px"><strong>初次编译可能会多耗费点时间</strong></span></p>
<p><span style="font-size: 14pt"><strong>5.4:使用uni-app</strong></span></p>
<p><span style="font-size: 15px">首先我们来了解一下uni-app的目录结构</span></p>
<p><span style="font-size: 14pt"><strong><img src="https://img2023.cnblogs.com/blog/2401301/202301/2401301-20230130201220404-212034403.png" alt="" width="896" height="611" loading="lazy"></strong></span></p>
<p><span style="font-size: 15px">了解完了目录结构后,我们就可以根据需求来进行编码</span></p>
<p><img src="https://img2023.cnblogs.com/blog/2401301/202301/2401301-20230130201823049-2137457368.png" alt="" width="711" height="253" loading="lazy"></p>
<p><span style="font-size: 15px">在HBbuiltX中保存后,微信小程序会自动更新代码</span></p>
<p><img src="https://img2023.cnblogs.com/blog/2401301/202301/2401301-20230130201918878-679926794.png" alt="" width="710" height="215" loading="lazy"></p>
<p><span style="font-size: 14pt"><strong>5.5:使用uni-app的组件</strong></span></p>
<p><span style="font-size: 15px">假设我们现在需要用一个日历的组件</span></p>
<p><span style="font-size: 15px">第一步:打开官网,选择组件,找到日历组件</span></p>
<p><span style="font-size: 14pt"><strong><img src="https://img2023.cnblogs.com/blog/2401301/202301/2401301-20230130202102973-284943563.png" alt="" width="770" height="371" loading="lazy"></strong></span></p>
<p><span style="font-size: 15px">&nbsp;直接copy代码到我们的HBuildX中,即可</span></p>
<p><img src="https://img2023.cnblogs.com/blog/2401301/202301/2401301-20230130202501318-48811337.png" alt="" width="385" height="561" loading="lazy"></p>
<p><span style="font-size: 14pt"><strong>5.6:微信小程序底部导航栏</strong></span></p>
<p><span style="font-size: 15px">还记得我们前面所描述的,需要修改或添加我们的底部导航栏,只需要修改<strong>app.json</strong>即可</span></p>
<p><span style="font-size: 15px">但在uni-app中,pages.json就相当于微信小程序中的app.json</span></p>
<p><strong><img src="https://img2023.cnblogs.com/blog/2401301/202301/2401301-20230130203104780-1472355237.png" alt="" width="897" height="395" loading="lazy"></strong></p>
<p><span style="font-size: 15px">申明一个"tabBar":他与pages同级,</span></p>
<p><span style="font-size: 15px">示例:</span></p>
<div class="language-json extra-class">
<div class="cnblogs_code">
<pre><span style="font-size: 16px"><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">tabBar</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">: {
      </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">color</span><span style="color: rgba(128, 0, 0, 1)">"</span>: <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">#999</span><span style="color: rgba(128, 0, 0, 1)">"</span>,<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">字体颜色</span>
      <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">selectedColor</span><span style="color: rgba(128, 0, 0, 1)">"</span>: <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">#000000</span><span style="color: rgba(128, 0, 0, 1)">"</span>,<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">选中后的字体颜色</span>
      <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">backgroundColor</span><span style="color: rgba(128, 0, 0, 1)">"</span>: <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">#FFF</span><span style="color: rgba(128, 0, 0, 1)">"</span>,<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">背景颜色</span>
      <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">list</span><span style="color: rgba(128, 0, 0, 1)">"</span>: [{<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">组件集合</span>
          <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">pagePath</span><span style="color: rgba(128, 0, 0, 1)">"</span>: <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">pages/index/index</span><span style="color: rgba(128, 0, 0, 1)">"</span>,<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">路径</span>
          <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">text</span><span style="color: rgba(128, 0, 0, 1)">"</span>: <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">组件</span><span style="color: rgba(128, 0, 0, 1)">"</span>,<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">名称</span>
          <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">iconPath</span><span style="color: rgba(128, 0, 0, 1)">"</span>: <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">static/c1.png</span><span style="color: rgba(128, 0, 0, 1)">"</span>,<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">图标</span>
          <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">selectedIconPath</span><span style="color: rgba(128, 0, 0, 1)">"</span>: <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">static/c1.png</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">选中后的图标</span>
<span style="color: rgba(0, 0, 0, 1)">      }, {
          </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">pagePath</span><span style="color: rgba(128, 0, 0, 1)">"</span>: <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">pages/text/text</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">,
          </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">text</span><span style="color: rgba(128, 0, 0, 1)">"</span>: <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">接口</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">,
          </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">iconPath</span><span style="color: rgba(128, 0, 0, 1)">"</span>: <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">static/c2.png</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">,
          </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">selectedIconPath</span><span style="color: rgba(128, 0, 0, 1)">"</span>: <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">static/c2.png</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">
      }]
      }
    }</span></span></pre>
</div>
<p><span style="font-size: 15px">效果图:</span></p>
<p><img src="https://img2023.cnblogs.com/blog/2401301/202301/2401301-20230130204353574-1038598496.png" alt="" width="372" height="645" loading="lazy"></p>
<p><span style="font-size: 14pt"><strong>5.7:接口</strong></span></p>
<p><span style="font-size: 16px">前言:作为一个合格的程序员,哪有不会对接第三方接口的道理,那么微信小程序官方,也为我们开发者贴心的准备了很多有用的接口给大家,供大家参考</span></p>
<p><span style="font-size: 16px">官方接口地址:https://developers.weixin.qq.com/miniprogram/dev/api/open-api/login/wx.pluginLogin.html</span></p>
<p><span style="font-size: 16px"><strong>实例演示:wx.getUserProfile</strong></span></p>
<p><span style="font-size: 16px; color: rgba(255, 0, 0, 1)"><strong>注:微信更新到8.0.29版本以后,wx.getUserProfile 就不弹出授权窗口了。</strong></span><span style="font-size: 16px; color: rgba(255, 0, 0, 1)"><strong>8.0.29版本的基础库为2.27.2</strong></span></p>
<p><span style="font-size: 16px; color: rgba(255, 0, 0, 1)"><strong><img src="https://img2023.cnblogs.com/blog/2401301/202301/2401301-20230130225418312-193525694.png" alt="" width="285" height="429" loading="lazy"></strong></span></p>
<p>完整代码:</p>
<div class="cnblogs_code">
<pre><span style="font-size: 16px">&lt;template&gt;
    &lt;view&gt;
      &lt;view <span style="color: rgba(0, 0, 255, 1)">class</span>=<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">login-bg</span><span style="color: rgba(128, 0, 0, 1)">"</span>&gt;
            &lt;view <span style="color: rgba(0, 0, 255, 1)">class</span>=<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">login-body</span><span style="color: rgba(128, 0, 0, 1)">"</span> open-type=<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">getUserInfo</span><span style="color: rgba(128, 0, 0, 1)">"</span> @click=<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">getUser</span><span style="color: rgba(128, 0, 0, 1)">"</span>&gt;<span style="color: rgba(0, 0, 0, 1)">
                微信授权登陆
            </span>&lt;/view&gt;
      &lt;/view&gt;
    &lt;/view&gt;
&lt;/template&gt;

&lt;script&gt;<span style="color: rgba(0, 0, 0, 1)">
    export </span><span style="color: rgba(0, 0, 255, 1)">default</span><span style="color: rgba(0, 0, 0, 1)"> {
      data() {
            </span><span style="color: rgba(0, 0, 255, 1)">return</span><span style="color: rgba(0, 0, 0, 1)"> {}
      },
      methods: {
            getUser(e) {
                wx.getUserProfile({
                  desc: </span><span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">用于完善会员资料</span><span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(0, 0, 0, 1)">,
                  success: (res) </span>=&gt;<span style="color: rgba(0, 0, 0, 1)"> {
                        console.log(res)
                  }
                })
            },
      }
    }
</span>&lt;/script&gt;

&lt;style&gt;
&lt;/style&gt;</span></pre>
</div>
<p><span style="font-size: 16px">效果图:</span></p>
<p><img src="https://img2023.cnblogs.com/blog/2401301/202301/2401301-20230130225113152-214322678.png" alt="" width="1197" height="529" loading="lazy"></p>
<p><strong>&nbsp;</strong></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<h1>四、视频</h1>
<p>【微信小程序开发】 https://www.bilibili.com/video/BV1pv4y1n7Zg/?share_source=copy_web&amp;vd_source=475a31f3c5d6353a782007cd4c638a8a</p>
<h1>五、作业</h1>
<p>(1)、完成微信发现页的页面布局</p>
<p><img src="https://img2023.cnblogs.com/blog/63651/202304/63651-20230418160154510-287743340.jpg" alt="" width="420" height="933" loading="lazy"></p>
<p>&nbsp;注意选项卡、与分组,尽量把信息存放在一个数组中,通过for属性遍历出内容。</p>
<p>(2)、完成下面的页面布局</p>
<p><img src="https://img2023.cnblogs.com/blog/63651/202304/63651-20230418160856906-1373798867.png" alt="" width="424" height="746"></p>
<p><img src="https://img2023.cnblogs.com/blog/63651/202304/63651-20230418160533881-796771547.png" alt="" loading="lazy"></p>
<p>(3)、完成一个猜数字游戏</p>
<p>首页是菜单选择页,共包含3个按钮,具体内容解释如下:<br>开始游戏:点击跳转到游戏页面;<br>游戏规则:点击跳转到游戏规则页面;<br>关于我们:点击跳转到关于我们页面。</p>
<p><img src="https://img2023.cnblogs.com/blog/63651/202304/63651-20230418160856843-1771493118.png" alt="" width="331" height="584"></p>
<p><img src="https://img2023.cnblogs.com/blog/63651/202304/63651-20230418160856877-1962834848.png" alt="" width="334" height="590"></p>
<p><img src="https://img2023.cnblogs.com/blog/63651/202304/63651-20230418160856882-1916534748.png" alt="" width="333" height="587"></p>
<p><img src="https://img2023.cnblogs.com/blog/63651/202304/63651-20230418160856877-120185311.png" alt="" width="330" height="583"></p><br><br>
来源:https://www.cnblogs.com/best/p/17325821.html
頁: [1]
查看完整版本: 微信小程序开发学习笔记(二)——小程序框架、组件、WXML