目录

slide-view(1090+)

概述

侧滑操作容器。该组件用于在视图下或视图外添加隐藏按钮,通过滑动手势触发。

使用限制

限制条件

说明

适用终端

手机、平板、智慧屏、车机

适用区域

全球

子组件

和div组件支持一样的子组件。

属性

除了支持通用属性以外,还支持如下属性。

名称

类型

默认值

是否必填

描述

edge

left | right

right

否

按钮位置靠左还是靠右。

enableslide

boolean

true

否

是否允许侧滑。

isopen

boolean

false

否

是否启用按钮区域。

layer

same | above

above

否

按钮组与主体的层级关系。

  • same:按钮组和主体同级
  • above:主体覆盖按钮组

buttons

array

-

是

按钮组,超过三项时,仅显示前三项。总宽度不超过侧滑操作容器宽度的2/3。

buttons属性说明:

  1. 按钮高度不允许修改。
  2. 按钮按添加顺序从左到右排序。

名称

类型

默认值

是否必填

描述

id

string

-

是

按钮ID,由buttonClick事件返回。

buttonWidth

length

-

否

按钮宽度。

icon

uri

-

否

按钮图标。

iconWidth

length

75px

否

按钮图标宽度。

iconHeight

length

75px

否

按钮图标高度。

iconBackgroundColor

color

#F2F2F2

否

图标圆形背景区域颜色,在backgroundType设置为icon时有效。

text

string

-

否

按钮文字。

textSize

number

15px

否

文字大小。

textColor

color

#000000

否

文字颜色。

backgroundColor

color

#F2F2F2

否

背景色。

backgroundType

fill | icon

fill

否

背景样式。

  • fill:表示填充整个背景。
  • icon:表示圆形背景区域仅显示图标,不显示文字。
说明:

如果icon和text均设置,则图标在上,文本在下,居中显示。如果仅设置icon或text,则居中显示。

secondaryConfirm

object

-

否

按钮二次确认状态。留空表示无此状态。

说明:

如果设置了二次确认,点击对应按钮则显示二次确认文本,背景色和按钮背景色相同。

secondaryConfirm属性说明:

名称

类型

默认值

是否必填

描述

text

string

-

是

二次确认文本。

textSize

number

15px

否

二次确认文本的大小。

textColor

color

#000000

否

二次确认文本的颜色。

样式

支持通用样式。

宽度和高度相关样式无效,根据组件内容设置高度。

事件

除了支持 通用事件 以外,还支持如下事件。

名称

参数

描述

open

-

打开按钮组区域时触发。

close

-

关闭按钮组区域时触发。

slide

{offset: offsetValue}

在按钮组区域滑动时触发。

offset:表示当前滑动距离。

buttonClick

{id: idValue

isSecondaryConfirm: isSecondaryConfirmValue}

点击按钮组时触发。

  • id:表示点击的按钮序号。
  • isSecondaryConfirm:表示点击对象是否是二次确认文本。

方法

名称

参数

描述

open

-

打开按钮组区域。

close

-

关闭按钮组区域。

open方法参数说明:

名称

类型

默认值

是否必填

描述

animation

boolean

true

否

是否启用打开动画。

close方法参数说明:

名称

类型

默认值

是否必填

描述

animation

boolean

true

否

是否启用关闭动画。

示例代码

<template>
  <!-- Only one root node is allowed in template. -->
  <div class="container">
    <text class="title">Left Slide</text>
    <div class="item-container">
      <slide-view class="slide-view" onButtonClick="buttonClick" buttons="{{slideButtons}}" layer="same" edge="left" enableslide="true">
        <div class="inner-div">
          <text class="text-div">左滑可以删除</text>
        </div>
      </slide-view>
    </div>
    <text class="title">enableslide = false</text>
    <slide-view class="slide-view" buttons="{{slideButtons}}" layer="same" isopen="false" edge="right" enableslide="false">
      <div class="inner-div">
        <text class="text-div">左滑可以删除</text>
      </div>
    </slide-view>
    <text class="title">isopen = true</text>
    <slide-view class="slide-view" buttons="{{slideButtons}}" layer="same" isopen="true" edge="left" enableslide="true">
      <div class="inner-div">
        <text class="text-div">左滑可以删除</text>
      </div>
    </slide-view>
    <text class="title">Right Slide</text>
    <slide-view class="slide-view" buttons="{{slideButtons}}" layer="same" isopen="false" edge="right" enableslide="true">
      <div class="inner-div">
        <text class="text-div">左滑可以删除</text>
      </div>
    </slide-view>
    <text class="title">Right Above Slide</text>
    <slide-view class="slide-view" buttons="{{slideButtons}}" layer="above" isopen="false" edge="right" enableslide="true">
      <div class="inner-div">
        <text class="text-div">左滑可以删除</text>
      </div>
    </slide-view>
    <text class="title">With Static Buttons</text>
    <slide-view id="slideview" class="slide-view" buttons="{{slideButtons}}" layer="same" isopen="false" edge="left" enableslide="true">
      <div class="inner-div">
        <text class="text-div">左滑可以删除</text>
      </div>
    </slide-view>
    <input type="button" value="Open" onclick="clickButton" />
    <input type="button" value="Close" onclick="closeclickButton" />
  </div>
</template>
<style>
  .container {
    flex-direction: column;
    justify-content: center;
    align-content: center;
    align-items: center;
  }

  .title {
    font-size: 50px;
    margin-top: 40px;
  }
  .buttons {
    margin: 10px;
    border-radius: 15px;
    padding: 15px;
  }
  .surfaceContainer {
    border-width: 2px;
    background-color: #d2691e;
    width: 100%;
    height: 150px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .buttonHolder {
    width: 750px;
    height: 150px;
    display: flex;
    flex-direction: row;
    align-items: center;
    text-align: center;
    background-color: #00ced1;
    justify-content: center;
  }
  .buttonHolder input {
    height: 100px;
  }
  .slide-view {
    width: 100%;
    height: 150px;
    background-color: #00008b;
  }
  .inner-div {
    height: 100px;
  }
  .text-div {
    color: #f0fff0;
  }
</style>
<script>
  import prompt from '@system.prompt'
  module.exports = {
    data: {
      title: 'World',
      slideButtons: [
        {
          id: "0",
          buttonWidth: '120px',
          clickButton: false,
          icon: '../Common/ic_update.png',
          text: 'Update',
          backgroundColor: '#FBD4FF',
          iconWidth: '50px',
          iconHeight: '50px',
          backgroundType: 'fill',
          secondaryConfirm: {
            text: "update ?",
            textSize: "12px",
            textColor: "#008000"
          }
        },
        {
          id: "1",
          buttonWidth: '150px',
          icon: '../Common/ic_delete.png',
          //clickButton : true,
          iconBackgroundColor: "#ff0000",
          backgroundColor: '#ff0000',
          backgroundType: 'icon',
          iconWidth: '70px',
          iconHeight: '65px',
          secondaryConfirm: {
            text: "delete ?",
            textSize: "12px",
            textColor: "#008000"
          }
        },
        {
          id: "2",
          buttonWidth: '180px',
          backgroundColor: '#ff0555',
          backgroundType: 'fill',
          text: 'Setting',
          textSize: '15px',
          textColor: '#f0f0f0'
        }
      ]
    },
    clickButton: function () {
      this.$element('slideview').open(true)
    },
    buttonClick(data) {
      const { id, isSecondaryConfirm } = data
      console.info(`### button:${id} is click, data is ${data} ###`)
      if (isSecondaryConfirm) {
        prompt.showToast({
          message: '第二次点击触发'
        })
      } else {
        prompt.showToast({
          message: '第一次点击触发'
        })
      }
    },
    closeclickButton: function () { this.$element('slideview').close(true) }
  }
</script>

版本更新说明

版本

发布日期

描述

1090

2022-05-19

第一次正式发布。