rax-modal
支持
Web / Weex / 阿里小程序 / 微信小程序 / 字节跳动小程序
描述
rax-modal
提供了弹出遮罩层的能力,为 Alert
, Confirm
等对话框组件提供底层能力。
安装
$ npm install rax-modal --save
属性
注:支持列表中的 代表h5 代表weex 代表小程序 代表头条小程序 代表快应用
示例
import { createElement, Component, render } from 'rax';
import Modal from 'rax-modal';
const Demo = props => {
const [visible, setVisible] = useState(false);
return [
<View onClick={() => setVisible(true)}>
<Text>open</Text>
</View>,
<Modal
visible={visible}
onHide={() => {
console.log('hide');
}}
onShow={() => {
console.log('show');
}}
onMaskClick={() => {
setVisible(false);
}}
contentStyle={{
position: 'absolute',
top: '150rpx',
width: '400rpx',
left: '175rpx',
}}
>
<Text>这里是弹窗内容</Text>
</Modal>,
];
};
render(<Demo />);
注意
在阿里巴巴系列小程序中使用该组件时需要开启 component2
。