引导 xGuid
预览
介绍
内部只可放置x-guid-item,遮罩与提示卡由当前激活的x-guid-item自己渲染。 目标元素必须有页面内唯一的id、可见、且不被隐藏(不可以封装在会裁切的容器里)。 蒸汽模式(HBuilderX 5.12+)各端页面默认可滚动,组件会自动把目标滚进可视区; 若页面在pages.json里配置了disableScroll:true(自定义导航栏/tabbar页面官方推荐),页面不可滚动, 自动滚动会失败并告警,此时请自行保证目标元素在可视区内,或者设置autoScroll=false。
平台兼容
| Harmony | H5 | andriod | IOS | 小程序 | UTS | UNIAPP-X SDK | version |
|---|---|---|---|---|---|---|---|
| ☑ | ☑ | ☑️ | ☑️ | ☑️ | ☑️ | 4.87+ | 1.1.21 |
文件路径
ts
@/uni_modules/tmx-ui/components/x-guid/x-guid.uvue使用
ts
<x-guid></x-guid>Props 属性
| 名称 | 说明 | 类型 | 默认值 |
|---|---|---|---|
| maskColor | 遮罩颜色 | string | 'rgba(0,0,0,0.4)' |
| activeId | 如果要双向绑定请使用v-model:active-id,您在子组件上定义的target-id属性,且是唯一的 | string | '' |
| defaultActiveId | 初始默认选中的id,为空不自动开始引导 | string | '' |
| zIndex | 遮罩与提示卡的层级,页面里有更高的固定层(底栏等)时可调大 | number | 50 |
| holePadding | 挖洞区域在目标矩形基础上向外扩的边距(px),目标贴边时更好看 | number | 0 |
| holeRadius | 高亮环圆角(px);四块矩形遮罩做不出圆角洞,圆角由环呈现,建议ringWidth >= holeRadius x 0.3 | number | 0 |
| ringColor | 高亮环颜色,为空不显示环 | string | '' |
| ringWidth | 高亮环粗细(px) | number | 2 |
| duration | 切换步骤时遮罩与提示卡的淡入时长(ms),0为不淡入 | number | 250 |
| autoScroll | 目标不在可视区时,是否自动滚动页面到目标处 | boolean | true |
| scrollOffset | 透传给uni.pageScrollTo的offsetTop,用于自定义导航栏留白; | number | 0 |
Events 事件
| 名称 | 参数 | 说明 |
|---|---|---|
| change | - | 用记点上、下步时的变化 |
| update:activeId | - | 双向同步手动控制,默认可以不配置,如果要自行控制请v-model:activeId |
| complete | - | 点击完成时触发 |
Slots 插槽
| 名称 | 说明 | 数据 |
|---|---|---|
| default | 插槽内只可放置x-guid-item | - |
Ref 方法
| 名称 | 参数 | 返回值 | 说明 |
|---|
示例文件路径
json
/pages/daohang/guid示例源码
uvue
vue
<template>
<!-- activeId -->
<!-- #ifdef MP-WEIXIN || MP-ALIPAY -->
<page-meta :page-style="`background-color:${xThemeConfigBgColor}`">
<navigation-bar :background-color="xThemeConfigNavBgColor"
:front-color="xThemeConfigNavFontColor"></navigation-bar>
</page-meta>
<!-- #endif -->
<x-sheet>
<x-text font-size="18" class="text-weight-b mb-8">引导 xGuid {{activeId}}</x-text>
<x-text color="#999999">引导组件,需要定位聚焦的元素必须在页面上不可以在子组件中或者隐藏中,并且必须要设定唯一id标识。蒸汽模式各端页面默认可滚动,目标不在可视区时组件会自动滚过去;页面若在pages.json里配置了disableScroll:true(自定义导航栏/tabbar),自动滚动会失败并告警,此时请自行保证目标可见或设置autoScroll=false。</x-text>
</x-sheet>
<view class="pa-12">
<x-button color="primary" :block="true" @click="onStart">重新开始引导</x-button>
</view>
<view style="height:50px"></view>
<view id="testId1" class="mx-16 mb-16 pa-16">
<x-text font-size="18" class="text-weight-b mb-8">节点1 testId1</x-text>
<view>
<x-text color="#999999">testId1</x-text>
</view>
</view>
<view style="height:200px"></view>
<view id="testId2" class="mx-16 mb-16 pa-16">
<x-text font-size="18" class="text-weight-b mb-8">节点2 testId2</x-text>
<view>
<x-text color="#999999">testId2</x-text>
</view>
</view>
<view style="height:550px"></view>
<x-sheet id="testId3">
<x-text font-size="18" class="text-weight-b mb-8">节点3 testId3</x-text>
<view>
<x-text color="#999999">testId3</x-text>
</view>
</x-sheet>
<view style="height:800px"></view>
<view class="mx-16 mb-16 pa-16" id="testId4">
<x-text font-size="18" class="text-weight-b mb-8">节点4 testId4</x-text>
<view class="flex flex-row flex-row-center-end">
<view>
<x-text color="#999999">testId4(在屏幕外,验证自动滚动定位)</x-text>
</view>
</view>
</view>
<view style="height:200px"></view>
<!--
hole-padding:挖洞在目标基础上外扩,目标贴边时更好看
ring-color / ring-width / hole-radius:高亮环,四块矩形遮罩做不出圆角洞,圆角由环呈现
z-index:遮罩与提示卡的层级,页面有更高的固定层(底栏等)时可调大
-->
<x-guid v-model:activeId="activeId" defaultActiveId="testId1" :hole-padding="6" ring-color="primary"
:ring-width="3" :hole-radius="8">
<x-guid-item v-for="(item,index) in 4" :key="item" :order="index" :targetId="`testId${item}`"
:title="`标题${item}`" :content="`testId${item}`"></x-guid-item>
</x-guid>
</template>
<script lang="ts" setup>
const activeId = ref('')
const onStart = () => {
activeId.value = 'testId1'
}
</script>
<style lang="scss">
</style>