• 小程序常见的组件


    1、view组件:相当于一个盒子,可以用来装一些别的组件,自带换行功能

    2、text组件:用来显示文字,没有换行功能

    3、input组件:主要用来获取客户输入信息的,一般在客户填写信息、提交数据、登录注册时用到,下表是关于input组件的详细说明:

    input

    基础库 1.0.0 开始支持,低版本需做兼容处理

    输入框。该组件是原生组件,使用时请注意相关限制

    属性

    类型

    默认值

    必填

    说明

    最低版本

    value

    string

    输入框的初始内容

    1.0.0

    type

    string

    text

    input 的类型

    1.0.0

    password

    boolean

    false

    是否是密码类型

    1.0.0

    placeholder

    string

    输入框为空时占位符

    1.0.0

    placeholder-style

    string

    指定 placeholder 的样式

    1.0.0

    placeholder-class

    string

    input-placeholder

    指定 placeholder 的样式类

    1.0.0

    disabled

    boolean

    false

    是否禁用

    1.0.0

    maxlength

    number

    140

    最大输入长度,设置为 -1 的时候不限制最大长度

    1.0.0

    cursor-spacing

    number

    0

    指定光标与键盘的距离,取 input 距离底部的距离和 cursor-spacing 指定的距离的最小值作为光标与键盘的距离

    1.0.0

    auto-focus

    boolean

    false

    (即将废弃,请直接使用 focus )自动聚焦,拉起键盘

    1.0.0

    focus

    boolean

    false

    获取焦点

    1.0.0

    confirm-type

    string

    done

    设置键盘右下角按钮的文字,仅在type='text'时生效

    1.1.0

    always-embed

    boolean

    false

    强制 input 处于同层状态,默认 focus 时 input 会切到非同层状态 (仅在 iOS 下生效)

    2.10.4

    confirm-hold

    boolean

    false

    点击键盘右下角按钮时是否保持键盘不收起

    1.1.0

    cursor

    number

    指定focus时的光标位置

    1.5.0

    selection-start

    number

    -1

    光标起始位置,自动聚集时有效,需与selection-end搭配使用

    1.9.0

    selection-end

    number

    -1

    光标结束位置,自动聚集时有效,需与selection-start搭配使用

    1.9.0

    adjust-position

    boolean

    true

    键盘弹起时,是否自动上推页面

    1.9.90

    hold-keyboard

    boolean

    false

    focus时,点击页面的时候不收起键盘

    2.8.2

    bindinput

    eventhandle

    键盘输入时触发,event.detail = {value, cursor, keyCode},keyCode 为键值,2.1.0 起支持,处理函数可以直接 return 一个字符串,将替换输入框的内容。

    1.0.0

    bindfocus

    eventhandle

    输入框聚焦时触发,event.detail = { value, height },height 为键盘高度,在基础库 1.9.90 起支持

    1.0.0

    bindblur

    eventhandle

    输入框失去焦点时触发,event.detail = {value: value}

    1.0.0

    bindconfirm

    eventhandle

    点击完成按钮时触发,event.detail = {value: value}

    1.0.0

    bindkeyboardheightchange

    eventhandle

    键盘高度发生变化的时候触发此事件,event.detail = {height: height, duration: duration}

    2.7.0

    4、button组件,详细说明见下表:

    button

    基础库 1.0.0 开始支持,低版本需做兼容处理

    按钮。

    属性

    类型

    默认值

    必填

    说明

    最低版本

    size

    string

    default

    按钮的大小

    1.0.0

    type

    string

    default

    按钮的样式类型

    1.0.0

    plain

    boolean

    false

    按钮是否镂空,背景色透明

    1.0.0

    disabled

    boolean

    false

    是否禁用

    1.0.0

    loading

    boolean

    false

    名称前是否带 loading 图标

    1.0.0

    form-type

    string

    用于 form 组件,点击分别会触发 form 组件的 submit/reset 事件

    1.0.0

    open-type

    string

    微信开放能力

    1.1.0

    hover-class

    string

    button-hover

    指定按钮按下去的样式类。当 hover-class="none" 时,没有点击态效果

    1.0.0

    hover-stop-propagation

    boolean

    false

    指定是否阻止本节点的祖先节点出现点击态

    1.5.0

    hover-start-time

    number

    20

    按住后多久出现点击态,单位毫秒

    1.0.0

    hover-stay-time

    number

    70

    手指松开后点击态保留时间,单位毫秒

    1.0.0

    lang

    string

    en

    指定返回用户信息的语言,zh_CN 简体中文,zh_TW 繁体中文,en 英文。

    1.3.0

    session-from

    string

    会话来源,open-type="contact"时有效

    1.4.0

    send-message-title

    string

    当前标题

    会话内消息卡片标题,open-type="contact"时有效

    1.5.0

    send-message-path

    string

    当前分享路径

    会话内消息卡片点击跳转小程序路径,open-type="contact"时有效

    1.5.0

    send-message-img

    string

    截图

    会话内消息卡片图片,open-type="contact"时有效

    1.5.0

    app-parameter

    string

    打开 APP 时,向 APP 传递的参数,open-type=launchApp时有效

    1.9.5

    show-message-card

    boolean

    false

    是否显示会话内消息卡片,设置此参数为 true,用户进入客服会话会在右下角显示"可能要发送的小程序"提示,用户点击后可以快速发送小程序消息,open-type="contact"时有效

    1.5.0

    bindgetuserinfo

    eventhandle

    用户点击该按钮时,会返回获取到的用户信息,回调的detail数据与wx.getUserInfo返回的一致,open-type="getUserInfo"时有效

    1.3.0

    bindcontact

    eventhandle

    客服消息回调,open-type="contact"时有效

    1.5.0

    bindgetphonenumber

    eventhandle

    获取用户手机号回调,open-type=getPhoneNumber时有效

    1.2.0

    binderror

    eventhandle

    当使用开放能力时,发生错误的回调,open-type=launchApp时有效

    1.9.5

    bindopensetting

    eventhandle

    在打开授权设置页后回调,open-type=openSetting时有效

    2.0.7

    bindlaunchapp

    eventhandle

    打开 APP 成功的回调,open-type=launchApp时有效

    2.4.4

    size 的合法值

    说明

    最低版本

    default

    默认大小

    mini

    小尺寸

    type 的合法值

    说明

    最低版本

    primary

    绿色

    default

    白色

    warn

    红色

    form-type 的合法值

    说明

    最低版本

    submit

    提交表单

    reset

    重置表单

    open-type 的合法值

    说明

    最低版本

    contact

    打开客服会话,如果用户在会话中点击消息卡片后返回小程序,可以从 bindcontact 回调中获得具体信息,具体说明 (小程序插件中不能使用

    1.1.0

    share

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

    1.2.0

    getPhoneNumber

    获取用户手机号,可以从bindgetphonenumber回调中获取到用户信息,具体说明 (小程序插件中不能使用

    1.2.0

    getUserInfo

    获取用户信息,可以从bindgetuserinfo回调中获取到用户信息 (小程序插件中不能使用

    1.3.0

    launchApp

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

    1.9.5

    openSetting

    打开授权设置页

    2.0.7

    feedback

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

    2.1.0

    lang 的合法值

    说明

    最低版本

    en

    英文

    zh_CN

    简体中文

    zh_TW

    繁体中文

     

    Bug & Tip

    1. tip: button-hover 默认为{background-color: rgba(0, 0, 0, 0.1); opacity: 0.7;}
    2. tip: bindgetphonenumber 从1.2.0 开始支持,但是在1.5.3以下版本中无法使用wx.canIUse进行检测,建议使用基础库版本进行判断。
    3. tip: 在bindgetphonenumber 等返回加密信息的回调中调用 wx.login 登录,可能会刷新登录态。此时服务器使用 code 换取的 sessionKey 不是加密时使用的 sessionKey,导致解密失败。建议开发者提前进行 login;或者在回调中先使用 checkSession 进行登录态检查,避免 login 刷新登录态。
    4. tip: 从 2.1.0 起,button 可作为原生组件的子节点嵌入,以便在原生组件上使用 open-type 的能力。
    5. tip: 目前设置了 form-type 的 button 只会对当前组件中的 form 有效。因而,将 button 封装在自定义组件中,而 form 在自定义组件外,将会使这个 button 的 form-type 失效。

    详细说明可以参考微信小程序官方文档:https://developers.weixin.qq.com/miniprogram/dev/component/

  • 相关阅读:
    Redhat6.4安装MongoDBv3.6.3
    windows模糊查询指定进程是否存在
    Linux普通用户不能使用TAB键、上下键
    零基础Python爬虫实现(百度贴吧)
    零基础Python爬虫实现(爬取最新电影排行)
    让bat批处理后台运行,不显示cmd窗口(完全静化)
    根据进程名监控进程(邮件提醒)
    android 开发中,必须要注意的知识点. (持续更新)
    Android上传文件至服务器
    为应用添加多个Activity与参数传递
  • 原文地址:https://www.cnblogs.com/young-dalong/p/14489857.html
Copyright © 2020-2023  润新知