vuejs 通知下级组件_带有vuejs的免费免费通知组件

vuejs 通知下级组件

Vue Toastify (Vue Toastify)

I wanted a component which I can use by passing props from the server on the first paint but which can also take statuses at run time. With this component it's has just become super easy.

我想要一个可以通过在第一次绘画时从服务器传递道具来使用的组件,但是它也可以在运行时获取状态。 有了这个组件,它变得非常容易。

To Install:

安装:

npm i vue-toastify

To Use:

使用方法:

1| Import the component:

1 | 导入组件:

import VueToastify from 'vue-toastify';

or with CDNs:

或使用CDN:

2| Register the component with Vue:

2 | 向Vue注册组件:

Vue.component('vue-toastify', VueToastify);

3| Add it inside your application:

3 | 将其添加到您的应用程序中:

<vue-toastify :your-props="here"></vue-toastify>

道具 (Props)

proptypedefaultdetails
statusObjectnullNot required, you may just let the component listen for future statuses.
canPauseBooleanfalseEnables pausing of the loader and the timeout on hover.
defaultTitleBooleantrueEnables the fallback to the type as the title.
eventHandlerString"EventBus"This entity will handle the events eg.: Eventbus.$on('notify', ...)
lightThemeBooleanfalseChange to the light theme.
errorDurationNumber8000The duration in milliseconds the error notification should be visible for.
successDurationNumber4000The duration in milliseconds the error notification should be visible for.
alertInfoDurationNumber6000The duration in milliseconds the error notification should be visible for.
initialDelayNumber750If a status passed as a prop, it may already starts the script before the page's content fully loaded. With this you can specify delay in milliseconds for the initial notification.
bodyMaxWidthNumber250Maximum width the body can take up. in px The rest of the notification will always be the same width.
positionString"bottom-right"Controls where the notification should appear. Accepted values are: 'top-left', 'top-center', 'top-right', 'left-center', 'right-center', 'bottom-left', 'bottom-center', 'bottom-right'. (when using centered positions the manual displacement will not work for the axis it's centered on)
positionXDistanceString"10px"Distance from the left or right depending on the position prop. All css values are accepted.
positionYDistanceString"10px"Distance from the top or bottom depending on the position prop. All css values are accepted.
Struts 类型 默认 细节
状态 目的 空值 不需要,您可以只让组件侦听将来的状态。
可以暂停 布尔型 启用暂停加载程序和悬停超时。
defaultTitle 布尔型 真正 启用后备类型作为标题。
eventHandler “ EventBus” 该实体将处理事件,例如:Eventbus。$ on('notify',...)
lightTheme 布尔型 更改为浅色主题。
errorDuration 8000 错误通知的持续时间(以毫秒为单位)。
successDuration 4000 错误通知的持续时间(以毫秒为单位)。
alertInfoDuration 6000 错误通知的持续时间(以毫秒为单位)。
initialDelay 750 如果状态作为道具传递,则它可能已经在页面内容完全加载之前启动了脚本。 这样,您可以指定初始通知的延迟(以毫秒为单位)。
bodyMaxWidth 250 机身可容纳的最大宽度。 以像素为单位其余的通知将始终具有相同的宽度。
位置 “右下” 控制通知应出现的位置。 可接受的值是:“左上”,“顶中”,“右上”,“左中”,“右中”,“左下”,“底中”,“右下” '。 (使用居中位置时,手动位移将不适用于其居中的轴)
positionXDistance “ 10px” 从左到右的距离取决于位置道具。 接受所有css值。
positionYDistance “ 10px” 距顶部或底部的距离取决于位置道具。 接受所有css值。

The status object takes the following attributes:

状态对象具有以下属性:

  • body = this is binded using v-html so you can go crazy with it

    body =这是使用v-html绑定的,因此您可以对其疯狂

  • (optional) title = if left empty, the type will be set as the title (first letter will always be capitalized)

    (可选)title =如果保留为空,则将类型设置为标题(首字母始终大写)

  • (optional) type = accepted values are: 'success', 'alert', 'info', 'error'. If no type given, it falls back to info

    (可选)type =接受的值是:“成功”,“警报”,“信息”,“错误”。 如果没有给出类型,则返回信息

  • (optional) canPause = you can overwrite what has already been set as
    a prop

    (可选)canPause =您可以覆盖已设置为
    一个道具

  • (optional) canTimeout = if set to false the notification has to be dismissed manually, otherwise it defaults to true

    (可选)canTimeout =如果设置为false,则必须手动关闭通知,否则默认为true

  • (optional) defaultTitle = should the title fall back to the type as the title

    (可选)defaultTitle =标题是否应退回到标题的类型

  • (optional) duration = this will take priority over all other duration settings

    (可选)持续时间=这将优先于所有其他持续时间设置

  • (optional) icon = you can customize the displayed icon within the circle using v-html

    (可选)icon =您可以使用v-html自定义圆圈中显示的图标

  • (optional) mode = available modes: 'prompt' which will display a yes/no button and emits the vtPrompt event with the respective boolean value (canTimeout automatically gets disabled) or 'loader' which will stay present until it hears the vtLoaderStop event

    (可选)模式=可用模式:“提示”,将显示是/否按钮,并发出带有相应布尔值的vtPrompt事件(canTimeout自动被禁用)或“加载程序”,该状态将一直存在,直到听到vtLoaderStop事件

杂项信息 (Miscellaneous info)

  • Events:

    大事记:

    • To add an event at runtime us the "vtNotify" event, passing the status object

      要在运行时添加事件,请通过状态对象传递“ vtNotify”事件
    • Manually dismissing notification will emit the event "vtDismissed"

      手动取消通知将发出事件“ vtDismissed”
    • Timer events are triggered at the corresponding points: "vtStarted", "vtPaused", "vtResumed", "vtFinished"

      计时器事件在以下相应点触发:“ vtStarted”,“ vtPaused”,“ vtResumed”,“ vtFinished”
    • Loader can be dismissed using the "vtLoadStop" event

      可以使用“ vtLoadStop”事件关闭加载程序
    • Prompt on answer will emit the "vtPrompt" event with a boolean value

      提示回答将发出带有布尔值的“ vtPrompt”事件
  • Pausing the notification is not supporting touch gestures but might work with long press on some devices.

    暂停通知不支持触摸手势,但长按某些设备可能会起作用。

  • 1.0.0 will be released once the notification container has been added.

    添加通知容器后,将释放1.0.0。

托多斯 (Todos)

  • Add a notification container which will enable displaying multiple notifications at the same time.

    添加一个通知容器,该容器将允许同时显示多个通知。

    • queueing notification

      排队通知
  • Add option that if url attribute specified on the status object, clicking on the notification will point the user to the url (SPA supported)

    添加选项,如果状态对象上指定了url属性,则单击通知将使用户指向url(支持SPA)

  • Increase test coverage

    增加测试范围

  • Add backdrop

    添加背景

  • Move the progress animation to use purely css

    移动进度动画以仅使用CSS

贡献 (Contribution)

  1. Fork the project

    分叉项目

  2. Set up project

    设置项目

    npm install
  3. Compile and use hot-reloads for development

    编译并使用热重装进行开发

    npm run serve
  4. Make your changes

    进行更改

  5. Lint and fix the code

    整理并修复代码

    npm run lint
  6. Run your tests

    运行测试

    npm run test
  7. Push to git and create a pull request.

    推送到git并创建请求请求。

翻译自: https://vuejsexamples.com/fuss-free-notification-component-with-vuejs/

vuejs 通知下级组件

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值