微信小程序之button按钮,navigator导航,rich-text 富文本

1,324 阅读1分钟

1 button按钮的开放能力


<!-- 
button按钮的开放能力

contact	打开客服会话,如果用户在会话中点击消息卡片后返回小程序,可以从bindcontact回
调中获得具体信息

share	触发用户转发,使用前建议先阅读使用指引	

getPhoneNumber	获取用户手机号,可以从bindgetphonenumber回调中获取到用户信息

getUserInfo	获取用户信息,可以从bindgetuserinfo回调中获取到用户信息	

launchApp	打开APP,可以通过app-parameter属性设定向APP传的参数具体说明	

openSetting	打开授权设置页

feedback	打开“意见反馈”页面,用户可提交反馈内容并上传日志,开发者可以登录小程
序管理后台后进入左侧菜单“客服反馈”页面获取到反馈内容

 -->
 
<button open-type="contact">contact按钮</button>
<button open-type="bindcontact">bindcontact按钮</button>
<button open-type="share">share按钮</button>
<button open-type="getPhoneNumber">getPhoneNumber按钮</button>
<button open-type="getUserInfo">getUserInfo按钮</button>
<button open-type="launchApp">launchApp按钮</button>
<button open-type="openSetting">openSetting按钮</button>
<button open-type="feedback">feedback按钮</button>

2 navigator导航


<!-- 导航组件 navigator -->

<!-- 
	 1 url 要跳转的页面路径 绝对路径  相对路径
     2 块级元素,有宽高,会换行
     3 target要跳转到当前的小程序还是其他的小程序页面
        self 默认值 自己的小程序页面
        minProgram  其他的小程序页面
     4 open-type 跳转的方式
        navigator(默认值) 保留当前页面,跳转到应用内的某一个页面,但是不能跳到tabbar页面
        redirect 关闭当前页面,跳转到应用内的某个页面,但是不能跳到tabbar页面
        switchTab 跳转到tabbar页面,并关闭其他所有非tabbar页面
        reLaunch 关闭所有页面,打开到应用内的某个页面
        navigateBack 关闭当前页面,返回上一页面或多级页面。可通过getCurrentPages() 获取当前的页面栈,决定需要返回几层。
        exit 退出其他的小程序,target="miniProgram"时生效。
 -->
 
 
<navigator url="/pages/demo01/demo01">导航组件</navigator>

<!-- 下面不能实现,因为不能跳转到tabbar页面 -->
<navigator url="/pages/index/index">跳转到tabbar页
面</navigator>

<navigator open-type="redirect" url="/pages/demo01/demo01">跳转
到redirect页面</navigator>

<navigator open-type="switchTab" url="/pages/index/index">switchTab直接跳
转到tabbar页面</navigator>

<navigator open-type="reLaunch" url="/pages/index/index">reLaunch可以
随便跳转</navigator>

<navigator open-type="navigateBack" url="/pages/index/index">navigateBack关闭
当前页面,返回上一页面或多级页面</navigator> 

3 rich-text 富文本标签

<!-- rich-text 富文本标签
1 nodes属性来实现
    接收标签字符串
    接收对象数组
 -->
 
 <!-- 第一种方式,标签字符串格式 -->
<rich-text nodes="{{name}}"></rich-text> 



 <!-- 第二种方式,接收数组对象的方式 -->
 <rich-text nodes="{{html}}"></rich-text>

第一种方式: 第二种方式:(也是在data里面)