PHP中navigator/button使用
<div id="article_content" class="article_content clearfix"><link rel="stylesheet" href="https://csdnimg.cn/release/blogv2/dist/mdeditor/css/editerView/kdoc_html_views-1a98987dfd.css">
<link rel="stylesheet" href="https://csdnimg.cn/release/blogv2/dist/mdeditor/css/editerView/ck_htmledit_views-6e43165c0a.css">
<div id="content_views" class="htmledit_views">
<p>解释说明在小程序中:使用navigator 组件的时候最重要的是里面的 <span style="color:#fe2c24;">open-type的默认跳转方式</span></p>
<p></p>
<h1 id="navigator">navigator</h1>
<p>页面链接。</p>
<table><thead><tr><th>属性</th><th>类型</th><th>默认值</th><th>必填</th><th>说明</th><th>最低版本</th></tr></thead><tbody><tr><td>target</td><td>string</td><td>self</td><td>否</td><td>在哪个目标上发生跳转,默认当前小程序</td><td><ahref="https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html">2.0.7</a></td></tr><tr><td>url</td><td>string</td><td></td><td>否</td><td>当前小程序内的跳转链接</td><td><ahref="https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html">1.0.0</a></td></tr><tr><td>open-type</td><td>string</td><td>navigate</td><td>否</td><td>跳转方式</td><td><ahref="https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html">1.0.0</a></td></tr><tr><td>delta</td><td>number</td><td>1</td><td>否</td><td>当 open-type 为 'navigateBack' 时有效,表示回退的层数</td><td><ahref="https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html">1.0.0</a></td></tr><tr><td>app-id</td><td>string</td><td></td><td>否</td><td>当<code>target="miniProgram"</code>时有效,要打开的小程序 appId</td><td><ahref="https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html">2.0.7</a></td></tr><tr><td>path</td><td>string</td><td></td><td>否</td><td>当<code>target="miniProgram"</code>时有效,打开的页面路径,如果为空则打开首页</td><td><ahref="https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html">2.0.7</a></td></tr><tr><td>extra-data</td><td>object</td><td></td><td>否</td><td>当<code>target="miniProgram"</code>时有效,需要传递给目标小程序的数据,目标小程序可在 <code>App.onLaunch()</code>,<code>App.onShow()</code> 中获取到这份数据。<ahref="https://developers.weixin.qq.com/miniprogram/dev/framework/app-service/app.html">详情</a></td><td><ahref="https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html">2.0.7</a></td></tr><tr><td>version</td><td>string</td><td>release</td><td>否</td><td>当<code>target="miniProgram"</code>时有效,要打开的小程序版本</td><td><ahref="https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html">2.0.7</a></td></tr><tr><td>short-link</td><td>string</td><td></td><td>否</td><td>当<code>target="miniProgram"</code>时有效,当传递该参数后,可以不传 app-id 和 path。链接可以通过【小程序菜单】->【复制链接】获取。</td><td><ahref="https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html">2.18.1</a></td></tr><tr><td>hover-class</td><td>string</td><td>navigator-hover</td><td>否</td><td>指定点击时的样式类,当<code>hover-class="none"</code>时,没有点击态效果</td><td><ahref="https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html">1.0.0</a></td></tr><tr><td>hover-stop-propagation</td><td>boolean</td><td>false</td><td>否</td><td>指定是否阻止本节点的祖先节点出现点击态</td><td><ahref="https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html">1.5.0</a></td></tr><tr><td>hover-start-time</td><td>number</td><td>50</td><td>否</td><td>按住后多久出现点击态,单位毫秒</td><td><ahref="https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html">1.0.0</a></td></tr><tr><td>hover-stay-time</td><td>number</td><td>600</td><td>否</td><td>手指松开后点击态保留时间,单位毫秒</td><td><ahref="https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html">1.0.0</a></td></tr><tr><td>bindsuccess</td><td>string</td><td></td><td>否</td><td>当<code>target="miniProgram"</code>时有效,跳转小程序成功</td><td><ahref="https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html">2.0.7</a></td></tr><tr><td>bindfail</td><td>string</td><td></td><td>否</td><td>当<code>target="miniProgram"</code>时有效,跳转小程序失败</td><td><ahref="https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html">2.0.7</a></td></tr><tr><td>bindcomplete</td><td>string</td><td></td><td>否</td><td>当<code>target="miniProgram"</code>时有效,跳转小程序完成</td><td><ahref="https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html">2.0.7</a></td></tr></tbody></table>
<p><strong>target 的合法值</strong></p>
<table><thead><tr><th>值</th><th>说明</th><th>最低版本</th></tr></thead><tbody><tr><td>self</td><td>当前小程序</td><td></td></tr><tr><td>miniProgram</td><td>其它小程序</td><td></td></tr></tbody></table>
<p><strong>open-type 的合法值</strong></p>
<table><thead><tr><th>值</th><th>说明</th><th>最低版本</th></tr></thead><tbody><tr><td>navigate</td><td>对应 <ahref="https://developers.weixin.qq.com/miniprogram/dev/api/route/wx.navigateTo.html">wx.navigateTo</a> 或 <ahref="https://developers.weixin.qq.com/miniprogram/dev/api/navigate/wx.navigateToMiniProgram.html">wx.navigateToMiniProgram</a> 的功能</td><td></td></tr><tr><td>redirect</td><td>对应 <ahref="https://developers.weixin.qq.com/miniprogram/dev/api/route/wx.redirectTo.html">wx.redirectTo</a> 的功能</td><td></td></tr><tr><td>switchTab</td><td>对应 <ahref="https://developers.weixin.qq.com/miniprogram/dev/api/route/wx.switchTab.html">wx.switchTab</a> 的功能</td><td></td></tr><tr><td>reLaunch</td><td>对应 <ahref="https://developers.weixin.qq.com/miniprogram/dev/api/route/wx.reLaunch.html">wx.reLaunch</a> 的功能</td><td><ahref="https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html">1.1.0</a></td></tr><tr><td>navigateBack</td><td>对应 <ahref="https://developers.weixin.qq.com/miniprogram/dev/api/route/wx.navigateBack.html">wx.navigateBack</a> 的功能</td><td><ahref="https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html">1.1.0</a></td></tr><tr><td>exit</td><td>退出小程序,<code>target="miniProgram"</code>时生效</td><td><ahref="https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html">2.1.0</a></td></tr></tbody></table>
<p><strong>version 的合法值</strong></p>
<table><thead><tr><th>值</th><th>说明</th><th>最低版本</th></tr></thead><tbody><tr><td>develop</td><td>开发版</td><td></td></tr><tr><td>trial</td><td>体验版</td><td></td></tr><tr><td>release</td><td>正式版,仅在当前小程序为开发版或体验版时此参数有效;如果当前小程序是正式版,则打开的小程序必定是正式版。</td><td></td></tr></tbody></table>
<p>使用限制</p>
<ol><li>需要用户确认跳转 从 <code>2.3.0</code> 版本开始,在跳转至其他小程序前,将统一增加弹窗,询问是否跳转,用户确认后才可以跳转其他小程序。如果用户点击取消,则回调 <code>fail cancel</code>。</li><li>每个小程序可跳转的其他小程序数量限制为不超过 10 个 从 2.4.0 版本以及指定日期(具体待定)开始,开发者提交新版小程序代码时,如使用了跳转其他小程序功能,则需要在代码配置中声明将要跳转的小程序名单,限定不超过 10 个,否则将无法通过审核。该名单可在发布新版时更新,不支持动态修改。配置方法详见 <ahref="https://developers.weixin.qq.com/miniprogram/dev/framework/config.html">配置</a>。调用此接口时,所跳转的 appId 必须在配置列表中,否则回调 <code>fail appId "${appId}" is not in navigateToMiniProgramAppIdList</code>。</li></ol>
<h1>button的使用方式</h1>
<h1 id="button"></h1>
<p><span style="color:#fe2c24;">button通过绑定获取用户信息,要使用微信内部的API 使用wx.getUserProfile来获取</span></p>
<p> 使用</p>
<p><span style="background-color:#38d8f0;"><button bindtap="getUserInfo"></button></span></p>
<p></p>
<p></p>
<p></p>
<blockquote>
<p>基础库 1.0.0 开始支持,低版本需做<ahref="https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html">兼容处理</a>。</p>
</blockquote>
<p>按钮。</p>
<table><thead><tr><th>属性</th><th>类型</th><th>默认值</th><th>必填</th><th>说明</th><th>最低版本</th></tr></thead><tbody><tr><td>size</td><td>string</td><td>default</td><td>否</td><td>按钮的大小</td><td><ahref="https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html">1.0.0</a></td></tr><tr><td>type</td><td>string</td><td>default</td><td>否</td><td>按钮的样式类型</td><td><ahref="https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html">1.0.0</a></td></tr><tr><td>plain</td><td>boolean</td><td>false</td><td>否</td><td>按钮是否镂空,背景色透明</td><td><ahref="https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html">1.0.0</a></td></tr><tr><td>disabled</td><td>boolean</td><td>false</td><td>否</td><td>是否禁用</td><td><ahref="https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html">1.0.0</a></td></tr><tr><td>loading</td><td>boolean</td><td>false</td><td>否</td><td>名称前是否带 loading 图标</td><td><ahref="https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html">1.0.0</a></td></tr><tr><td>form-type</td><td>string</td><td></td><td>否</td><td>用于 <ahref="https://developers.weixin.qq.com/miniprogram/dev/component/form.html">form</a> 组件,点击分别会触发 <ahref="https://developers.weixin.qq.com/miniprogram/dev/component/form.html">form</a> 组件的 submit/reset 事件</td><td><ahref="https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html">1.0.0</a></td></tr><tr><td>open-type</td><td>string</td><td></td><td>否</td><td>微信开放能力</td><td><ahref="https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html">1.1.0</a></td></tr><tr><td>hover-class</td><td>string</td><td>button-hover</td><td>否</td><td>指定按钮按下去的样式类。当 <code>hover-class="none"</code> 时,没有点击态效果</td><td><ahref="https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html">1.0.0</a></td></tr><tr><td>hover-stop-propagation</td><td>boolean</td><td>false</td><td>否</td><td>指定是否阻止本节点的祖先节点出现点击态</td><td><ahref="https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html">1.5.0</a></td></tr><tr><td>hover-start-time</td><td>number</td><td>20</td><td>否</td><td>按住后多久出现点击态,单位毫秒</td><td><ahref="https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html">1.0.0</a></td></tr><tr><td>hover-stay-time</td><td>number</td><td>70</td><td>否</td><td>手指松开后点击态保留时间,单位毫秒</td><td><ahref="https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html">1.0.0</a></td></tr><tr><td>lang</td><td>string</td><td>en</td><td>否</td><td>指定返回用户信息的语言,zh_CN 简体中文,zh_TW 繁体中文,en 英文。</td><td><ahref="https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html">1.3.0</a></td></tr><tr><td>session-from</td><td>string</td><td></td><td>否</td><td>会话来源,open-type="contact"时有效</td><td><ahref="https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html">1.4.0</a></td></tr><tr><td>send-message-title</td><td>string</td><td>当前标题</td><td>否</td><td>会话内消息卡片标题,open-type="contact"时有效</td><td><ahref="https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html">1.5.0</a></td></tr><tr><td>send-message-path</td><td>string</td><td>当前分享路径</td><td>否</td><td>会话内消息卡片点击跳转小程序路径,open-type="contact"时有效</td><td><ahref="https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html">1.5.0</a></td></tr><tr><td>send-message-img</td><td>string</td><td>截图</td><td>否</td><td>会话内消息卡片图片,open-type="contact"时有效</td><td><ahref="https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html">1.5.0</a></td></tr><tr><td>app-parameter</td><td>string</td><td></td><td>否</td><td>打开 APP 时,向 APP 传递的参数,open-type=launchApp时有效</td><td><ahref="https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html">1.9.5</a></td></tr><tr><td>show-message-card</td><td>boolean</td><td>false</td><td>否</td><td>是否显示会话内消息卡片,设置此参数为 true,用户进入客服会话会在右下角显示"可能要发送的小程序"提示,用户点击后可以快速发送小程序消息,open-type="contact"时有效</td><td><ahref="https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html">1.5.0</a></td></tr><tr><td>bindgetuserinfo</td><td>eventhandle</td><td></td><td>否</td><td>用户点击该按钮时,会返回获取到的用户信息,回调的detail数据与<ahref="https://developers.weixin.qq.com/miniprogram/dev/api/open-api/user-info/wx.getUserInfo.html">wx.getUserInfo</a>返回的一致,open-type="getUserInfo"时有效</td><td><ahref="https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html">1.3.0</a></td></tr><tr><td>bindcontact</td><td>eventhandle</td><td></td><td>否</td><td>客服消息回调,open-type="contact"时有效</td><td><ahref="https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html">1.5.0</a></td></tr><tr><td>bindgetphonenumber</td><td>eventhandle</td><td></td><td>否</td><td>获取用户手机号回调,open-type=getPhoneNumber时有效</td><td><ahref="https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html">1.2.0</a></td></tr><tr><td>binderror</td><td>eventhandle</td><td></td><td>否</td><td>当使用开放能力时,发生错误的回调,open-type=launchApp时有效</td><td><ahref="https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html">1.9.5</a></td></tr><tr><td>bindopensetting</td><td>eventhandle</td><td></td><td>否</td><td>在打开授权设置页后回调,open-type=openSetting时有效</td><td><ahref="https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html">2.0.7</a></td></tr><tr><td>bindlaunchapp</td><td>eventhandle</td><td></td><td>否</td><td>打开 APP 成功的回调,open-type=launchApp时有效</td><td><ahref="https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html">2.4.4</a></td></tr></tbody></table>
<p><strong>size 的合法值</strong></p>
<table><thead><tr><th>值</th><th>说明</th><th>最低版本</th></tr></thead><tbody><tr><td>default</td><td>默认大小</td><td></td></tr><tr><td>mini</td><td>小尺寸</td><td></td></tr></tbody></table>
<p><strong>type 的合法值</strong></p>
<table><thead><tr><th>值</th><th>说明</th><th>最低版本</th></tr></thead><tbody><tr><td>primary</td><td>绿色</td><td></td></tr><tr><td>default</td><td>白色</td><td></td></tr><tr><td>warn</td><td>红色</td><td></td></tr></tbody></table>
<p><strong>form-type 的合法值</strong></p>
<table><thead><tr><th>值</th><th>说明</th><th>最低版本</th></tr></thead><tbody><tr><td>submit</td><td>提交表单</td><td></td></tr><tr><td>reset</td><td>重置表单</td><td></td></tr></tbody></table>
<p><strong>open-type 的合法值</strong></p>
<table><thead><tr><th>值</th><th>说明</th><th>最低版本</th></tr></thead><tbody><tr><td>contact</td><td>打开客服会话,如果用户在会话中点击消息卡片后返回小程序,可以从 bindcontact 回调中获得具体信息,<ahref="https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/customer-message/customer-message.html">具体说明</a> (<em>小程序插件中不能使用</em>)</td><td><ahref="https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html">1.1.0</a></td></tr><tr><td>share</td><td>触发用户转发,使用前建议先阅读<ahref="https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/share.html#%E4%BD%BF%E7%94%A8%E6%8C%87%E5%BC%95">使用指引</a></td><td><ahref="https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html">1.2.0</a></td></tr><tr><td>getPhoneNumber</td><td>获取用户手机号,可以从bindgetphonenumber回调中获取到用户信息,<ahref="https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/getPhoneNumber.html">具体说明</a> (<em>小程序插件中不能使用</em>)</td><td><ahref="https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html">1.2.0</a></td></tr><tr><td>getUserInfo</td><td>获取用户信息,可以从bindgetuserinfo回调中获取到用户信息 (<em>小程序插件中不能使用</em>)</td><td><ahref="https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html">1.3.0</a></td></tr><tr><td>launchApp</td><td>打开APP,可以通过app-parameter属性设定向APP传的参数<ahref="https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/launchApp.html">具体说明</a></td><td><ahref="https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html">1.9.5</a></td></tr><tr><td>openSetting</td><td>打开授权设置页</td><td><ahref="https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html">2.0.7</a></td></tr><tr><td>feedback</td><td>打开“意见反馈”页面,用户可提交反馈内容并上传<ahref="https://developers.weixin.qq.com/miniprogram/dev/api/base/debug/wx.getLogManager.html">日志</a>,开发者可以登录<ahref="https://mp.weixin.qq.com/">小程序管理后台</a>后进入左侧菜单“客服反馈”页面获取到反馈内容</td><td><ahref="https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html">2.1.0</a></td></tr></tbody></table>
<p><strong>lang 的合法值</strong></p>
<table><thead><tr><th>值</th><th>说明</th><th>最低版本</th></tr></thead><tbody><tr><td>en</td><td>英文</td><td></td></tr><tr><td>zh_CN</td><td>简体中文</td><td></td></tr><tr><td>zh_TW</td><td>繁体中文</td><td></td></tr></tbody></table>
<h2 id="Bug-Tip">Bug & Tip</h2>
<ol><li><code>tip</code>: <code>button-hover</code> 默认为<code>{background-color: rgba(0, 0, 0, 0.1); opacity: 0.7;}</code></li><li><code>tip</code>: <code>bindgetphonenumber</code> 从1.2.0 开始支持,但是在1.5.3以下版本中无法使用<ahref="https://developers.weixin.qq.com/miniprogram/dev/api/base/wx.canIUse.html">wx.canIUse</a>进行检测,建议使用基础库版本进行判断。</li><li><code>tip</code>: 在<code>bindgetphonenumber</code> 等返回加密信息的回调中调用 <ahref="https://developers.weixin.qq.com/miniprogram/dev/api/open-api/login/wx.login.html">wx.login</a> 登录,可能会刷新登录态。此时服务器使用 code 换取的 sessionKey 不是加密时使用的 sessionKey,导致解密失败。建议开发者提前进行 <code>login</code>;或者在回调中先使用 <code>checkSession</code> 进行登录态检查,避免 <code>login</code> 刷新登录态。</li><li><code>tip</code>: 从 2.1.0 起,button 可作为原生组件的子节点嵌入,以便在原生组件上使用 <code>open-type</code> 的能力。</li><li><code>tip</code>: 目前设置了 <code>form-type</code> 的 <code>button</code> 只会对当前组件中的 <code>form</code> 有效。因而,将 <code>button</code> 封装在自定义组件中,而 <code>form</code> 在自定义组件外,将会使这个 <code>button</code> 的 <code>form-type</code> 失效。</li></ol>
</div>
</div>
<div id="treeSkill"></div>
页:
[1]