文档管理中心
API参考快应用组件slide-view(1090+)

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

否

是否启用关闭动画。

示例代码

收起
自动换行
深色代码主题
复制
  1. <template>
  2. <!-- Only one root node is allowed in template. -->
  3. <div class="container">
  4. <text class="title">Left Slide</text>
  5. <div class="item-container">
  6. <slide-view class="slide-view" onButtonClick="buttonClick" buttons="{{slideButtons}}" layer="same" edge="left" enableslide="true">
  7. <div class="inner-div">
  8. <text class="text-div">左滑可以删除</text>
  9. </div>
  10. </slide-view>
  11. </div>
  12. <text class="title">enableslide = false</text>
  13. <slide-view class="slide-view" buttons="{{slideButtons}}" layer="same" isopen="false" edge="right" enableslide="false">
  14. <div class="inner-div">
  15. <text class="text-div">左滑可以删除</text>
  16. </div>
  17. </slide-view>
  18. <text class="title">isopen = true</text>
  19. <slide-view class="slide-view" buttons="{{slideButtons}}" layer="same" isopen="true" edge="left" enableslide="true">
  20. <div class="inner-div">
  21. <text class="text-div">左滑可以删除</text>
  22. </div>
  23. </slide-view>
  24. <text class="title">Right Slide</text>
  25. <slide-view class="slide-view" buttons="{{slideButtons}}" layer="same" isopen="false" edge="right" enableslide="true">
  26. <div class="inner-div">
  27. <text class="text-div">左滑可以删除</text>
  28. </div>
  29. </slide-view>
  30. <text class="title">Right Above Slide</text>
  31. <slide-view class="slide-view" buttons="{{slideButtons}}" layer="above" isopen="false" edge="right" enableslide="true">
  32. <div class="inner-div">
  33. <text class="text-div">左滑可以删除</text>
  34. </div>
  35. </slide-view>
  36. <text class="title">With Static Buttons</text>
  37. <slide-view id="slideview" class="slide-view" buttons="{{slideButtons}}" layer="same" isopen="false" edge="left" enableslide="true">
  38. <div class="inner-div">
  39. <text class="text-div">左滑可以删除</text>
  40. </div>
  41. </slide-view>
  42. <input type="button" value="Open" onclick="clickButton" />
  43. <input type="button" value="Close" onclick="closeclickButton" />
  44. </div>
  45. </template>
  46. <style>
  47. .container {
  48. flex-direction: column;
  49. justify-content: center;
  50. align-content: center;
  51. align-items: center;
  52. }
  53. .title {
  54. font-size: 50px;
  55. margin-top: 40px;
  56. }
  57. .buttons {
  58. margin: 10px;
  59. border-radius: 15px;
  60. padding: 15px;
  61. }
  62. .surfaceContainer {
  63. border-width: 2px;
  64. background-color: #d2691e;
  65. width: 100%;
  66. height: 150px;
  67. text-align: center;
  68. display: flex;
  69. align-items: center;
  70. justify-content: center;
  71. }
  72. .buttonHolder {
  73. width: 750px;
  74. height: 150px;
  75. display: flex;
  76. flex-direction: row;
  77. align-items: center;
  78. text-align: center;
  79. background-color: #00ced1;
  80. justify-content: center;
  81. }
  82. .buttonHolder input {
  83. height: 100px;
  84. }
  85. .slide-view {
  86. width: 100%;
  87. height: 150px;
  88. background-color: #00008b;
  89. }
  90. .inner-div {
  91. height: 100px;
  92. }
  93. .text-div {
  94. color: #f0fff0;
  95. }
  96. </style>
  97. <script>
  98. import prompt from '@system.prompt'
  99. module.exports = {
  100. data: {
  101. title: 'World',
  102. slideButtons: [
  103. {
  104. id: "0",
  105. buttonWidth: '120px',
  106. clickButton: false,
  107. icon: '../Common/ic_update.png',
  108. text: 'Update',
  109. backgroundColor: '#FBD4FF',
  110. iconWidth: '50px',
  111. iconHeight: '50px',
  112. backgroundType: 'fill',
  113. secondaryConfirm: {
  114. text: "update ?",
  115. textSize: "12px",
  116. textColor: "#008000"
  117. }
  118. },
  119. {
  120. id: "1",
  121. buttonWidth: '150px',
  122. icon: '../Common/ic_delete.png',
  123. //clickButton : true,
  124. iconBackgroundColor: "#ff0000",
  125. backgroundColor: '#ff0000',
  126. backgroundType: 'icon',
  127. iconWidth: '70px',
  128. iconHeight: '65px',
  129. secondaryConfirm: {
  130. text: "delete ?",
  131. textSize: "12px",
  132. textColor: "#008000"
  133. }
  134. },
  135. {
  136. id: "2",
  137. buttonWidth: '180px',
  138. backgroundColor: '#ff0555',
  139. backgroundType: 'fill',
  140. text: 'Setting',
  141. textSize: '15px',
  142. textColor: '#f0f0f0'
  143. }
  144. ]
  145. },
  146. clickButton: function () {
  147. this.$element('slideview').open(true)
  148. },
  149. buttonClick(data) {
  150. const { id, isSecondaryConfirm } = data
  151. console.info(`### button:${id} is click, data is ${data} ###`)
  152. if (isSecondaryConfirm) {
  153. prompt.showToast({
  154. message: '第二次点击触发'
  155. })
  156. } else {
  157. prompt.showToast({
  158. message: '第一次点击触发'
  159. })
  160. }
  161. },
  162. closeclickButton: function () { this.$element('slideview').close(true) }
  163. }
  164. </script>

版本更新说明

展开

版本

发布日期

描述

1090

2022-05-19

第一次正式发布。

在 API参考 中进行搜索
请输入您想要搜索的关键词