0.1.1-beta.0 • Published 3 years ago
ph-notification v0.1.1-beta.0
vue-template
install
npm install ph-notification
interface indtoduction
export type PhNotifyType = 'success'|'danger'|'warning'|'info'
export type NotifyPosition = 'right-top'|'right-bottom'|'left-top'|'left-bottom'
export type PhNotifyOpt={
type?:PhNotifyType,
closable?:boolean,
position?:NotifyPosition,
autoClose?:boolean,
clickable?:boolean,
icon?:string, //icon-save
iconClass?:string,//icon
iconColor?:string //red
}
export interface PhNotifyReturn{
click(fn:(...a:any[])=>void):PhNotifyReturn,
close(fn:(...a:any[])=>void):PhNotifyReturn
}
javascript
import Notification from 'ph-notification'
//全局
app.use(Notification)
//子组件
this.$phNotify(c:string,opt?:PhNotifyOpt
//注意 如需想类型提醒需要如下定义typescript
declare module '@vue/runtime-core' {
export interface ComponentCustomProperties extends Phoeon{
$phNotify : (c:string,opt?:PhNotifyOpt)=>PhNotifyReturn,
}
}
//按需 以下为静态方法,无需模版
Notification.
notify(c:string,opt?:PhNotifyOpt).click(fn).close(fn)
success(c:string,opt?:PhNotifyOpt).click(fn).close(fn)
warning(c:string,opt?:PhNotifyOpt).click(fn).close(fn)
info(c:string,opt?:PhNotifyOpt).click(fn).close(fn)
danger(c:string,opt?:PhNotifyOpt).click(fn).close(fn)