@szlx/easy-popup

1.0.5 • Public • Published

uview-easy-popup

Installtion

npm i @szlx/easy-popup

Usage

<easy-popup ref="popup">
  <template v-slot:children="{ component }">
    <!--
      调用show的时候, 传入的component参数将在这里获取到
      用于判断当前popup需要打开渲染的组件是哪个
      这么做是考虑到不用每需要弹窗打开一个组件就写一个popup标签
    -->
    <TestComponent v-if="component === 'TestComponent'" />
    <TestComponent1 v-if="component === 'TestComponent1'" />
  </template>
</easy-popup>
import Vue from 'vue'
import EasyPopup from '@szlx/easy-popup'
Vue.component('easy-popup', EasyPopup)

const instance = this.$refs.popup.show({
  component: 'TestComponent',
  data: 'hello world',
  emits: ['test'],
  onTest: () => {}
})

// 第二种事件交互方式也是可用的, 不需要手动处理off
instance.on('test', () => {})

Props

在组件内可以调用$emit('update-property', { property, value })修改下面任意参数

参数名 说明 类型 必填 默认值
component 渲染组件的 name 值 string true
padding popup 默认 padding boolean false
mode popup 弹出方向 string bottom
height popup 高度 string 70vh
background popup 背景色 string #ffffff
expandable 开启收缩功能 boolean false
zIndex popup 层级 number 10075
onInit 组件初始化函数名, 打开弹窗后会被调用(如果有) string popupLoad
data 传递给 onInit 方法的数据 any -
emits 组绑定的事件名(用法参考示例) string[] -
onXxxx 组绑定的事件回调函数, 例: { emits: ['click'], onClick: () => {} } function -
onClose popup 关闭回调, 同时会调用 @close function -
onOpen popup 打开回调, 同时会调用 @open function -
nextTick popup 的 nextTick 回调, 入参是 component function -

show 方法返回值

参数名 说明 类型
close 关闭 popup function
on 绑定组件事件函数 function

Package Sidebar

Install

npm i @szlx/easy-popup

Weekly Downloads

0

Version

1.0.5

License

none

Unpacked Size

9.15 kB

Total Files

3

Last publish

Collaborators

  • szlx