Guide
组件类型:UxGuideComponentPublicInstance
支持动画效果,支持跳过和插槽自定义
平台兼容性
UniApp X
Android | iOS | web | 鸿蒙 Next | 小程序 |
---|---|---|---|---|
√ | √ | √ | x | √ |
UniApp Vue Nvue
Android | iOS | web | 鸿蒙 Next | 小程序 |
---|---|---|---|---|
x | x | √ | x | x |
Props
属性名 | 类型 | 默认值 | 说明 |
---|---|---|---|
default | Slot | 默认插槽 | |
datas | Array | 数据 | |
width | Any | 300 | 宽度 |
skip | Boolean | true | 跳过 |
offset | Any | 5 | 偏移 |
opacity | Number | 0.8 | 遮罩透明度0-1 |
confirmText | String | '完成' | 完成按钮文字 |
autoscroll | Boolean | true | 自动滚动到锚点 |
Events
事件名 | 说明 | 参数 |
---|---|---|
scroll | 锚点无法触达需要滚动时触发 | |
change | 步骤改变时触发 | |
skip | 跳过时触发 | |
end | 结束时触发 |
示例代码
html
<template>
<ux-page :stack="showDoc">
<ux-navbar :title="title" :border="false">
<template v-slot:right>
<!-- #ifndef MP -->
<ux-button theme="text" icon="/static/tip.png" :icon-size="22" @click="onDoc()"></ux-button>
<!-- #endif -->
</template>
</ux-navbar>
<ux-scroll :scrollTop="scrollTop">
<ux-card class="gtag" direction="column" icon="flag-filled" title="引导" :bold="true">
<ux-text text="支持动画效果,支持跳过和插槽自定义"></ux-text>
</ux-card>
<ux-card class="gtag" direction="column" icon="arrowright" title="标题" :bold="true">
<view id="step1">
<ux-placeholder :height="100">
<ux-row justify="center" align="center" style="height: 100%;">
<ux-text prefix-icon="soapbubble-filled" text="节点1"></ux-text>
</ux-row>
</ux-placeholder>
</view>
</ux-card>
<ux-card class="gtag" direction="column" icon="arrowright" title="标题" :bold="true">
<ux-placeholder :height="100">
<ux-row justify="center" align="center" style="height: 100%;">
<view id="step2">
<ux-text prefix-icon="soapbubble-filled" text="节点2"></ux-text>
</view>
</ux-row>
</ux-placeholder>
</ux-card>
<ux-card class="gtag" direction="column" icon="arrowright" title="标题" :bold="true">
<ux-placeholder :height="100">
<ux-row justify="right" align="center" style="height: 100%;">
<view id="step3">
<ux-text prefix-icon="soapbubble-filled" text="节点3"></ux-text>
</view>
</ux-row>
</ux-placeholder>
</ux-card>
<ux-card class="gtag" direction="column" icon="arrowright" title="标题" :bold="true">
<view id="step4">
<ux-placeholder :height="100">
<ux-row justify="center" align="center" style="height: 100%;">
<ux-text prefix-icon="soapbubble-filled" text="节点4"></ux-text>
</ux-row>
</ux-placeholder>
</view>
</ux-card>
<ux-placeholder :height="200">
<ux-row justify="center" align="center" style="height: 100%;">
<ux-text prefix-icon="soapbubble-filled" text="真的没有了~"></ux-text>
</ux-row>
</ux-placeholder>
</ux-scroll>
<ux-guide v-if="showGuide" ref="uxGuideRef" :datas="guides" confirm-text="开启新的旅程" @scroll="scroll" @skip="end" @end="end" @change="change"></ux-guide>
</ux-page>
</template>
<template>
<ux-page :stack="showDoc">
<ux-navbar :title="title" :border="false">
<template v-slot:right>
<!-- #ifndef MP -->
<ux-button theme="text" icon="/static/tip.png" :icon-size="22" @click="onDoc()"></ux-button>
<!-- #endif -->
</template>
</ux-navbar>
<ux-scroll :scrollTop="scrollTop">
<ux-card class="gtag" direction="column" icon="flag-filled" title="引导" :bold="true">
<ux-text text="支持动画效果,支持跳过和插槽自定义"></ux-text>
</ux-card>
<ux-card class="gtag" direction="column" icon="arrowright" title="标题" :bold="true">
<view id="step1">
<ux-placeholder :height="100">
<ux-row justify="center" align="center" style="height: 100%;">
<ux-text prefix-icon="soapbubble-filled" text="节点1"></ux-text>
</ux-row>
</ux-placeholder>
</view>
</ux-card>
<ux-card class="gtag" direction="column" icon="arrowright" title="标题" :bold="true">
<ux-placeholder :height="100">
<ux-row justify="center" align="center" style="height: 100%;">
<view id="step2">
<ux-text prefix-icon="soapbubble-filled" text="节点2"></ux-text>
</view>
</ux-row>
</ux-placeholder>
</ux-card>
<ux-card class="gtag" direction="column" icon="arrowright" title="标题" :bold="true">
<ux-placeholder :height="100">
<ux-row justify="right" align="center" style="height: 100%;">
<view id="step3">
<ux-text prefix-icon="soapbubble-filled" text="节点3"></ux-text>
</view>
</ux-row>
</ux-placeholder>
</ux-card>
<ux-card class="gtag" direction="column" icon="arrowright" title="标题" :bold="true">
<view id="step4">
<ux-placeholder :height="100">
<ux-row justify="center" align="center" style="height: 100%;">
<ux-text prefix-icon="soapbubble-filled" text="节点4"></ux-text>
</ux-row>
</ux-placeholder>
</view>
</ux-card>
<ux-placeholder :height="200">
<ux-row justify="center" align="center" style="height: 100%;">
<ux-text prefix-icon="soapbubble-filled" text="真的没有了~"></ux-text>
</ux-row>
</ux-placeholder>
</ux-scroll>
<ux-guide v-if="showGuide" ref="uxGuideRef" :datas="guides" confirm-text="开启新的旅程" @scroll="scroll" @skip="end" @end="end" @change="change"></ux-guide>
</ux-page>
</template>
ts
<script setup>
import * as plus from '@/uni_modules/ux-plus'
import { UxGuideItem } from '@/uni_modules/ux-frame'
const scrollTop = ref(0)
const uxGuideRef = ref<UxGuideComponentPublicInstance | null>(null)
const guides = [{
id: 'step1',
text: '1. 适配深色模式,可随系统自动切换'
},{
id: 'step2',
text: '2. 支持配置主色调'
},{
id: 'step3',
text: '3. 支持字体大小、字体颜色、内边距、外边距等20+项配置'
},{
id: 'step4',
text: '4. 持续更新的高性能UI组件库'
}] as UxGuideItem[]
const showGuide = ref(true)
const title = ref('')
function scroll(top: number) {
scrollTop.value = top
}
function change(step: number) {
console.log(step);
}
function end(step: number) {
showGuide.value = false
}
const showDoc = ref(false)
function onDoc() {
plus.openWeb({
title: '在线文档',
url: 'https://www.uxframe.cn/component/guide.html',
// blur: 1,
success: () => {
showDoc.value = true
},
complete: () => {
showDoc.value = false
}
})
}
onLoad((e) => {
title.value = e['title'] ?? ''
})
</script>
<script setup>
import * as plus from '@/uni_modules/ux-plus'
import { UxGuideItem } from '@/uni_modules/ux-frame'
const scrollTop = ref(0)
const uxGuideRef = ref<UxGuideComponentPublicInstance | null>(null)
const guides = [{
id: 'step1',
text: '1. 适配深色模式,可随系统自动切换'
},{
id: 'step2',
text: '2. 支持配置主色调'
},{
id: 'step3',
text: '3. 支持字体大小、字体颜色、内边距、外边距等20+项配置'
},{
id: 'step4',
text: '4. 持续更新的高性能UI组件库'
}] as UxGuideItem[]
const showGuide = ref(true)
const title = ref('')
function scroll(top: number) {
scrollTop.value = top
}
function change(step: number) {
console.log(step);
}
function end(step: number) {
showGuide.value = false
}
const showDoc = ref(false)
function onDoc() {
plus.openWeb({
title: '在线文档',
url: 'https://www.uxframe.cn/component/guide.html',
// blur: 1,
success: () => {
showDoc.value = true
},
complete: () => {
showDoc.value = false
}
})
}
onLoad((e) => {
title.value = e['title'] ?? ''
})
</script>
css
<style lang="scss">
</style>
<style lang="scss">
</style>