uniapp的button的open-type
时间: 2024-05-29 15:12:06 浏览: 212
uniapp中的button组件提供了open-type属性,用于指定按钮的点击行为。以下是open-type属性的几种取值及其对应的行为:
1. navigate:跳转到指定页面,需在button上添加url属性,如:`<button open-type="navigate" url="/pages/index"></button>`
2. redirect:关闭当前页面,跳转到应用内的某个页面,需在button上添加url属性,如:`<button open-type="redirect" url="/pages/index"></button>`
3. switchTab:跳转到应用内的某个tab页面,需在button上添加url属性,如:`<button open-type="switchTab" url="/pages/index"></button>`
4. reLaunch:关闭所有页面,打开应用内的某个页面,需在button上添加url属性,如:`<button open-type="reLaunch" url="/pages/index"></button>`
5. contact:打开客服会话,需在button上添加session-from属性和app-parameter属性,如:`<button open-type="contact" session-from="uni-app" app-parameter="uni"></button>`
6. share:打开分享面板,需在button上添加share-button属性和share参数,如:`<button open-type="share" share-button="true" share="{title: '分享标题', path: '/pages/index', imageUrl: '/static/logo.png'}"></button>`
7. getUserInfo:获取用户信息,需在button上添加bindgetuserinfo属性,如:`<button open-type="getUserInfo" bindgetuserinfo="onGetUserInfo"></button>`
8. getPhoneNumber:获取用户手机号码,需在button上添加bindgetphonenumber属性,如:`<button open-type="getPhoneNumber" bindgetphonenumber="onGetPhoneNumber"></button>`
9. launchApp:打开外部应用,需在button上添加app-parameter属性和extinfo属性,如:`<button open-type="launchApp" app-parameter="myapp://path?query=xxx" extinfo="{id: 'xxx', type: 'yyy'}"></button>`
阅读全文