# t-movable-area
MovableArea 可移动区域
t-movable-area 组件介绍
t-movable-area 是可移动区域组件,用于承载 t-movable-view 组件。通过在视图层内部处理拖动,避免逻辑层和视图层之间的通信损耗,实现流畅的拖动体验。
t-movable-area 平台兼容
| Harmony | H5 | Android | iOS | 小程序 | UTS |
|---|---|---|---|---|---|
| ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
t-movable-area 基础用法
基础用法参考 demo/movable/movable.uvue,配合 t-movable-view 使用。
vue
<template>
<view class="p-15">
<tui-theme-switch></tui-theme-switch>
<t-card class="mb-15"
title="MovableArea 拖动区域"
sub-title="补充官方movable-area不支持APP,小程序开发的时候,避免过多的写条件编译"></t-card>
<t-section title="拖动"
class="mb-15"></t-section>
<t-movable-area :class="[`w-100% h-150 mb-15 tvg r-10`]">
<t-movable-view :class="[`twh-60 r-10 fc tbg-pn`]"
:x="x"
:y="y"
direction="all"
:inertia="true"
:out-of-bounds="true"
@change="onChange">
<t-text :fore="true"
type="primary">Text</t-text>
</t-movable-view>
</t-movable-area>
<t-section title="绽放"
class="mb-15"></t-section>
<t-movable-area :class="[`w-100% h-200 mb-15 tvg r-10`]"
:scale-area="true">
<t-movable-view :class="[`twh-60 r-10 fc tbg-pn`]"
:x="x"
:y="y"
:scale-value="scale"
:scale="true"
:inertia="true"
:out-of-bounds="true"
direction="all"
@change="onChange">
<t-text :fore="true"
type="primary">Text</t-text>
</t-movable-view>
</t-movable-area>
<t-button @click="scale+=0.2"
type="primary">缩放</t-button>
</view>
</template>
<script setup>
const x = ref(0)
const y = ref(0)
const scale = ref(1)
function onChange(e : UTSJSONObject) {
// console.log(e)
}
</script>t-movable-area Props
| 属性名 | 说明 | 类型 | 默认值 |
|---|---|---|---|
scaleArea | 是否支持双指缩放区域 | boolean | true |
path | 点击组件后跳转的页面路径 | string | '' |
hover | 是否启用点击效果 | boolean | false |
type | 组件主题类型 | string | '' |
disabled | 是否禁用 | boolean | false |
effect | 组件显示主题 | string | '' |
size | 组件尺寸 | string | '' |
t-movable-area Slots
| 插槽名 | 说明 |
|---|---|
default | 默认插槽,放置 t-movable-view 子组件 |