ew-message 一个基于typescript封装的消息提示框插件

ew-message

一个基于 typescript 而封装的消息提示框插件,可用于不使用ui组件库的中小型网站中。

安装与使用

安装

scss 复制代码
npm install ew-message --save-dev//或者 yarn add ew-message

引入

js 复制代码
<script src="./dist/ew-message.min.js"></script>

消息提示框插件如下:

js 复制代码
const msg1 = ewMessage('默认消息提示框');
const msg1 = ewMessage({
  content: '默认消息提示框'
});

option 配置对象有如下参数:

ts 复制代码
interface ewMessageOption {
  content: string; //消息提示框内容,必传参数
  center?: boolean; //消息提示框内容是否居中
  type?: string; //消息提示框类型,有四种: info,success,warning,error
  duration?: number; //消息提示框消失时间
  showClose?: boolean; //是否显示关闭按钮
  stylePrefix?: string; //消息提示框样式前缀,注意插件有检测如果导入了样式文件,则这个配置无效
  showTypeIcon?: boolean; // 是否显示类型图标,默认为true
  typeIcon?: string; // 自定义类型图标
  closeIcon?: string; // 自定义关闭按钮图标
}

ps: 推荐使用导入样式文件的方式。

cdn 引入

js 复制代码
//样式引入
// CDN:https://www.unpkg.com/ew-message/dist/ew-message.min.css
// CDN:https://www.unpkg.com/ew-message/dist/ew-message.min.js

在组件中使用

js 复制代码
import ewMessage from 'ewMessage';
//  导入样式
import 'ew-message/dist/ew-message.min.css';
const msg = ewMessage(option); //option为配置对象,详情见前述

当然也可以不引入样式,插件检测了如果不导入样式文件,则会自动添加样式,并且也可以给样式添加类名前缀自定义样式。

更多详情参阅文档官网介绍ew-message;

更新日志

  • 0.0.1 ~ 0.0.4: 添加了消息提示框的基本功能。
  • 0.0.5: 修改了 ts 类型导入。
  • 0.0.6: 消息提示框添加了销毁 destroy 方法。
  • 0.0.7: 完善了 ts 类型,新增了最大关闭时间属性 maxDuration,修改了默认关闭时间。
  • 0.0.8: 新增了 showTypeIcon 和 typeIcon 属性以及 closeIcon,用于配置图标,新增了工具方法 createElement。
相关推荐
cc.ChenLy5 分钟前
Lottie-Web 技术指南:让动画开发更简单高效
前端
bug总结9 分钟前
前端流程图vueflow
前端·流程图
清水白石00811 分钟前
Python 数据建模指南:dataclass、TypedDict 与 Pydantic 的选型博弈
前端·javascript·python
ZC跨境爬虫12 分钟前
跟着 MDN 学CSS day_23:(表单与表格综合样式化实战)
前端·javascript·css·ui·html·tensorflow
国科安芯14 分钟前
AS32S601芯片抗辐照性能试验验证与空间环境适应性分析
前端·分布式·单片机·嵌入式硬件·架构·risc-v·安全性测试
波诺波17 分钟前
最小 SOFA XML 场景结构 0-base.scn
xml·java·前端
风骏时光牛马18 分钟前
基于Python实现智能聊天机器人完整代码案例
前端
anyup21 分钟前
【最全鸿蒙】uni-app 转鸿蒙:从打包失败到商店上架成功全过程
前端·uni-app·harmonyos
用户7138742290025 分钟前
浏览器安全机制与现代 SPA 认证架构深度解析
前端
Momo__26 分钟前
Node Modules Inspector:Vue 团队出品的依赖分析神器
前端·vue.js·npm