手摸手写一个Modal插件
首先封装一个组件modal,其中各个参数的作用在上面都进行了解析
主角组件
modal.js
import { Fragment, Component } from 'react';
import c from './index.less';
/*
* @visible {Boolean} 是否展示
* @closeName {String} 取消键名字
* @okName {String} 确认键名字
* @buttonable {Boolean} 底部按钮是否隐藏
* @cancelable {Boolean} 取消按钮是否隐藏
* @closeable {Boolean} x按钮是否隐藏
* @onOk {Function} 确认键回调函数
* @onCancel {Function} 取消键和x按钮回调函数
*/
export default class Modal extends Component {
constructor() {
//继承React.Component
super();
this.state = {};
}
render() {
const { closeName, okName, buttonabl