0.1.7 • Published 12 months ago

weapp-new-user-guide v0.1.7

Weekly downloads
-
License
ISC
Repository
github
Last release
12 months ago

微信小程序新手引导组件

一个简单的微信小程序新手引导组件,支持镂空引导元素,不遮挡引导元素的操作,支持定义样式

img

引入

npm i weapp-new-user-guide

安装完在小程序开发者工具中点击菜单栏:工具 -> 构建 npm

在需要使用的页面的 json 文件中添加配置

{
  "usingComponents": {
    "weapp-new-user-guide": "/miniprogram_npm/weapp-new-user-guide/index"
  }
}

使用

<weapp-new-user-guide
  wx:if="{{ showGuide }}"
  options="{{ guideData }}"
  bind:stepChange="onGuideStepChange"
  bind:end="onGuideEnd"
/>
Page({
  ...
  data: {
    showGuide: true,
    guideData: [
      { selector: '.image_wrapper .tempImage', tips: '步骤1' },
      { selector: '.bottomIcon .setting', tips: '步骤2' },
      { selector: '.bottomIcon .playback', tips: '步骤3' },
      { selector: '.bottomIcon .buyBtn', tips: '步骤4', scrollViewSelector: '.scroll-view' },
    ],
  },
  ...
})

Props

参数类型默认值说明
optionsArray[]引导步骤数据
options[].selectorString''引导元素选择器
options[].tipsString''引导提示文字
options[].scrollViewSelectorString''引导元素所在的滚动元素选择器,如果引导元素在滚动元素内,需要传入该参数,否则引导元素可能会被滚动元素遮挡
hollowOutBooleanfalse是否镂空引导元素,关闭时点击镂空位置会触发下一步,开启时高亮区域为镂空状态,点击事件可以正常触发,需要自己调用 nextStep 方法进行下一步
initDelayNumber500初始化延迟时间,防止元素还未创建时就开始查询节点,单位ms
zIndexNumber3000层级
pageKeyString''页面标识,用于区分同页面的不同引导,不传默认为路由字符串
animationTimeNumber250动画时间,单位ms
tipsWrapperClassString''提示文字容器类名
nextBtnTextString'下一步'下一步按钮文字
nextBtnClassString''下一步按钮类名
endBtnTextString'我知道了'完成按钮文字
endBtnClassString''完成按钮类名
jumpAllBtnTextString'全部跳过'跳过按钮文字
maskPaddingNumber5遮罩层与引导元素的间距,单位px

Events

事件名说明参数
stepChange引导步骤变化时触发{ pageKey: string, step: number }
end引导结束时触发{ pageKey: string }

Methods

方法名说明参数
nextStep下一步-
<weapp-new-user-guide
  wx:if="{{ showGuide }}"
  id="guide"
  hollowOut
  options="{{ guideData }}"
  bind:stepChange="onGuideStepChange"
  bind:end="onGuideEnd"
/>
this.selectComponent('#guide')?.nextStep()
0.1.7

12 months ago

0.1.6

12 months ago

0.1.5

12 months ago

0.1.4

12 months ago

0.1.3

12 months ago