1.5.1 • Published 1 year ago

@wines/popover v1.5.1

Weekly downloads
-
License
-
Repository
-
Last release
1 year ago

@wines/popover

弹出气泡式的卡片浮层。

使用指南

在 page.json 中引入组件

{
  "navigationBarTitleText": "wux-popover",
  "usingComponents": {
    "wux-popover": "@wines/popover"
  }
}

示例

<view class="page">
	<view class="page__hd">
		<view class="page__title">Popover</view>
		<view class="page__desc">气泡框</view>
	</view>
	<view class="page__bd">
		<view class="sub-title">Placement</view>
		<view class="button-sp-area">
			<wux-popover
			 placement="topLeft"
			 mask
			 title="Title"
			 content="Content"
			>
				<wux-button type="light">topLeft</wux-button>
			</wux-popover>
		</view>
		<view class="button-sp-area">
			<wux-popover placement="top" title="Title" content="Content">
				<wux-button type="light">top</wux-button>
			</wux-popover>
		</view>
		<view class="button-sp-area">
			<wux-popover placement="topRight" title="Title" content="Content">
				<wux-button type="light">topRight</wux-button>
			</wux-popover>
		</view>
		<view class="button-sp-area text-left">
			<wux-popover placement="rightTop" title="Title" content="Content">
				<wux-button type="light">rightTop</wux-button>
			</wux-popover>
		</view>
		<view class="button-sp-area text-left">
			<wux-popover placement="right" title="Title" content="Content">
				<wux-button type="light">right</wux-button>
			</wux-popover>
		</view>
		<view class="button-sp-area text-left">
			<wux-popover placement="rightBottom" title="Title" content="Content">
				<wux-button type="light">rightBottom</wux-button>
			</wux-popover>
		</view>
		<view class="button-sp-area">
			<wux-popover placement="bottomRight" title="Title" content="Content">
				<wux-button type="light">bottomRight</wux-button>
			</wux-popover>
		</view>
		<view class="button-sp-area">
			<wux-popover placement="bottom" title="Title" content="Content">
				<wux-button type="light">bottom</wux-button>
			</wux-popover>
		</view>
		<view class="button-sp-area">
			<wux-popover placement="bottomLeft" title="Title" content="Content">
				<wux-button type="light">bottomLeft</wux-button>
			</wux-popover>
		</view>
		<view class="button-sp-area text-right">
			<wux-popover placement="leftBottom" title="Title" content="Content">
				<wux-button type="light">leftBottom</wux-button>
			</wux-popover>
		</view>
		<view class="button-sp-area text-right">
			<wux-popover placement="left" title="Title" content="Content">
				<wux-button type="light">left</wux-button>
			</wux-popover>
		</view>
		<view class="button-sp-area text-right">
			<wux-popover placement="leftTop" title="Title" content="Content">
				<wux-button type="light">leftTop</wux-button>
			</wux-popover>
		</view>
		<view class="sub-title">Default Visible</view>
		<view class="button-sp-area text-left">
			<wux-popover
			 defaultVisible
			 placement="rightBottom"
			 title="Title"
			 content="Content"
			>
				<wux-button type="light">rightBottom</wux-button>
			</wux-popover>
		</view>
		<view class="sub-title">Custom style</view>
		<view class="button-sp-area">
			<wux-popover
			 placement="top"
			 title="Title"
			 content="Content"
			 body-style="width: 300px;"
			>
				<wux-button type="light">top</wux-button>
			</wux-popover>
		</view>
		<view class="sub-title">Theme = dark</view>
		<view class="button-sp-area">
			<wux-popover
			 theme="dark"
			 placement="top"
			 title="Title"
			 content="Content"
			>
				<wux-button type="light">top</wux-button>
			</wux-popover>
		</view>
		<view class="sub-title">Slot</view>
		<view class="button-sp-area">
			<wux-popover placement="top">
				<wux-button type="light">top</wux-button>
				<view slot="title" style="padding: 20rpx; color: red;">Title</view>
				<view slot="content" style="padding: 20rpx">Content</view>
			</wux-popover>
		</view>
		<view class="sub-title">Controlled</view>
		<view class="button-sp-area">
			<wux-popover
			 visible="{{ visible }}"
			 controlled
			 placement="top"
			 title="Title"
			 bind:change="onChange"
			>
				<view slot="content" style="padding: 20rpx" bindtap="hide">Close</view>
				<wux-button type="light">top</wux-button>
			</wux-popover>
		</view>
	</view>
</view>
import './index.less';

Page({
  data: {
    visible: false,
  },
  hide() {
    this.setData({
      visible: false,
    });
  },
  onChange(e) {
    console.log('onChange', e);
    this.setData({
      visible: e.detail.visible,
    });
  },
});

API

Popover props

参数类型描述默认值
prefixClsstring自定义类名前缀wux-popover
classNamesany过渡的类名,更多内置过渡效果请参考 AnimationGroupwux-animate--fadeIn
themestring气泡框主题,可选值为 light、darklight
titlestring提示标题-
contentstring提示内容-
bodyStylestring,object自定义样式-
defaultVisibleboolean默认是否显隐,当 controlledfalse 时才生效false
placementstring气泡框位置,可选值为 top、left、right、bottom、topLeft、topRight、bottomLeft、bottomRight、leftTop、leftBottom、rightTop、rightBottomtop
triggerstring触发行为,可选值为 clickclick
visibleboolean用于手动控制浮层显隐,当 controlledtrue 时才生效false
controlledboolean是否受控 说明文档false
maskboolean是否显示蒙层false
maskClosableboolean点击蒙层是否允许关闭true
bind:changefunction显示隐藏的回调函数-

Popover slot

名称描述
-自定义内容
title自定义提示标题
content自定义提示内容

Popover externalClasses

名称描述
wux-class根节点样式类
1.5.1

1 year ago

1.5.0

1 year ago

1.3.5

2 years ago

1.4.0

2 years ago

1.3.4

3 years ago

1.3.2

3 years ago

1.3.1

3 years ago

1.3.0

3 years ago