codecamp

百度智能小程序 视图容器

view 视图容器

解释:视图容器,相当于 html 中的 div ,可将页面分割为独立的、不同的部分。如果需要使用滚动视图,请使用 scroll-view

属性说明

属性名类型默认值必填说明

hover-class

String

none

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

hover-stop-propagation

Boolean

false

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

hover-start-time

Number

50

按住后出现点击态的时间长度,单位毫秒

hover-stay-time

Number

400

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

示例 

在开发者工具中打开

代码示例 1: 横向布局

<view class="wrap">
    <view class="card-area">
        <view class="top-description border-bottom">横向布局</view>
        <view class="rowlike">
            <view 
                class="color-a"
                hover-class="hover"
                hover-stop-propagation="false"
                hover-start-time="100"
                hover-stay-time="200">
                <text>A</text>
            </view>
            <view class="color-b">
                <text>B</text>
            </view>
            <view class="color-c">
                <text>C</text>
            </view>
        </view>
    </view>
</view>
.rowlike {
    margin: .2rem .57rem;
    display: flex;
}

.rowlike view {
    flex: 1;
    text-align: center;
    font-size: .16rem;
    color: #FFF;
    width: .91rem;
    height: 1.22rem;
    line-height: 1.22rem;
}

.color-a {
    background-color: #5B9FFF;
}

.color-b {
    background-color: #85B8FF;
}

.color-c {
    background-color: #ADCFFF;
}

.hover {
    opacity: .2;
}

代码示例 2: 纵向布局

<view class="wrap">
    <view class="card-area">
        <view class="top-description border-bottom">纵向布局</view>
        <view class="collike">
            <view class="color-a">
                <text>A</text>
            </view>
            <view class="color-b">
                <text>B</text>
            </view>
            <view class="color-c">
                <text>C</text>
            </view>
        </view>
    </view>
</view>
.collike {
    margin: .2rem .68rem;
    flex-direction: column;
}

.collike view {
    height: 1.07rem;
    width: 2.5rem;
    line-height: 1.07rem;
    flex: 1;
    text-align: center;
    font-size: .16rem;
    color: #FFF;
}
.color-a {
    background-color: #5B9FFF;
}
.color-b {
    background-color: #85B8FF;
}
.color-c {
    background-color: #ADCFFF;
}
.hover {
    opacity: .2;
}

Bug & Tip

  • Tip:如果需要使用滚动视图,请使用 scroll-view。
  • Tip:从基础库版本 1.12.0 开始支持事件捕获、冒泡。


百度智能小程序 滑块视图容器子项
百度智能小程序 图标
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

百度智能小程序开发文档

百度智能小程序 组件

百度智能小程序 地图

百度智能小程序 画布

百度智能小程序 API

百度智能小程序 界面

百度智能小程序 关注小程序引导组件

百度智能小程序 自定义组件

百度智能小程序 媒体

百度智能小程序 设备

百度智能小程序 拨打电话

百度智能小程序 内存警报

百度智能小程序 手机联系人

百度智能小程序 用户截屏事件

百度智能小程序 第三方平台

百度智能小程序 开放接口

百度智能小程序 百度收银支付

百度智能小程序 分包预下载

百度智能小程序 数据分析

百度智能小程序 服务端

百度智能小程序 云开发

百度智能小程序 初始化

百度智能小程序 云函数

百度智能小程序 服务端初始化

百度智能小程序 服务器获取上下文

百度智能小程序 服务端云函数

百度智能小程序 开发教程

百度智能小程序 功能开发

百度智能小程序 基本原理

百度智能小程序 小程序自动化

百度智能小程序 视频教程

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }