vue 单一页面

Vue Flash消息 (vue-flash-message)

The component to display single flash message to user. It has styles presets, but can be easily customized by passing style object as argument.

向用户显示单个Flash消息的组件。 它具有样式预设,但是可以通过将样式对象作为参数来轻松自定义。

View Demo 查看演示 Download Source 下载源

建立 (Setup)

npm i @smartweb/vue-flash-message

组态 (Configuration)

import Vue from 'vue';
import FlashMessage from '@smartweb/vue-flash-message';
Vue.use(FlashMessage);

You can pass configuration object as second argument

您可以将配置对象作为第二个参数传递

Vue.use(FlashMessage, config);

配置对象 (Configuration object)

Property Type Description Default
name String It is a name of the component and alias for the EventBus global property. 'flashMessage'
tag String Custom tag for the component to use in your application. 'FlashMesage'
time Number Duration (in ms) of the message display (can be customized during message call). 8000
icon Boolean If you would like to use icons as default. true
属性 类型 描述 默认
名称 它是组件的名称以及EventBus全局属性的别名。 “ flashMessage”
标签 在您的应用程序中使用的组件的自定义标签。 “ FlashMesage”
时间 消息显示的持续时间(以毫秒为单位)(可以在消息通话期间自定义)。 8000
图标 布尔型 如果您想使用图标作为默认值。 真正

用法 (Usage)

Put the component into your template

将组件放入模板

<FlashMessage></FlashMessage>

Now you can access it by using global EventBus alias (that is "flashMessage" by default) of your Vue instance

现在,您可以通过使用Vue实例的全局EventBus别名(默认为“ flashMessage”)来访问它

this.flashMessage.show({status: 'error', title: 'Error Message Title', message: 'Oh, you broke my heart! Shame on you!'})

方法 (Methods)

You also can use shorthands without status property.

您也可以使用没有状态属性的速记。

this.flashMessage.error({title: 'Error Message Title', message: 'Oh, you broke my heart! Shame on you!'});
this.flashMessage.warning({title: 'Warning Message Title', message: 'Don\'t stop me nooooow....!'});
this.flashMessage.info({title: 'Info Message Title', message: 'Just want you to know, that Vue is so cool'});
this.flashMessage.success({title: 'Success Message Title', message: 'Hoorah, it is my fist npm package and it works!'});

数据对象 (Data Object)

The first argument - is data object.

第一个参数-是数据对象。

Property Type Description
status String Status of component. Default presets: 'error', 'warning', 'info', 'success'
title String Title of your message
message String Text of your message
time Number Duration (in ms) of the single message display
icon Boolean If you would like to use icons for this single message
flashMessageStyle Object style Object for flashMessage block
iconStyle Object style Object for icon block. You can pass your own icon as 'backgroundImage'
contentStyle Object Style of content block
titleStyle Object Styles for title
textStyle Object Styles for text
属性 类型 描述
状态 组件的状态。 默认预设:“错误”,“警告”,“信息”,“成功”
标题 讯息标题
信息 您的留言文字
时间 单个消息显示的持续时间(以毫秒为单位)
图标 布尔型 如果您想对这条消息使用图标
flashMessageStyle 目的 flashMessage块的样式对象
iconStyle 目的 样式图标块的对象。 您可以将自己的图标作为“ backgroundImage”传递
contentStyle 目的 内容块样式
titleStyle 目的 标题样式
textStyle 目的 文字样式

Example:

例:

methods: {deleteTrouble() {this.$axios.delete(`/delete/trouble/${trouble.id}`).then( res => {let { status, data, error } = res.data;if(status) {this.flashMessage.success({title: 'Don\'t Warry',message: 'Be Happy!',time: 5000,flashMessageStyle: {backgroundColor: 'linear-gradient(#e66465, #9198e5)'}});}else {this.flashMessage.error({title: error.name || 'Error', message: error.message});}}).catch(e);}}

回呼 (Callbacks)

As second argument you can pass object with two properties: "mounted" and "destroyed".

作为第二个参数,您可以传递具有两个属性的对象:“ mount”和“ destroyed”。

Property Type Description
mounted Function Will be invoked, when flashMessage appears
destroyed Function Will be invoked, when flashMessage gone
属性 类型 描述
已安装 功能 出现flashMessage时将被调用
被毁 功能 当flashMessage消失时将被调用

Example:

例:

<p>{{ text }}</p>
<button @click="clickHandler" type="button" name="button">Show Text!</button>
methods: {showText() {this.text = 'Hello from callback!'},clearText() {this.text = 'Bye... 1, ..2, ..3';setTimeout( () => this.text = '', 3000);},clickHandler() {this.flashMessage.info({title: 'Ooooooops!',message: 'Do you see this text? Wtf?'},{mounted: showText,destroyed: clearText})}}

翻译自: https://vuejsexamples.com/single-flash-message-with-vue/

vue 单一页面

vue 单一页面_带有vue的单一Flash消息相关推荐

  1. vue 幻灯片组件_带有vue的漂亮幻灯片组件

    vue 幻灯片组件 Vue-tantan堆栈 (vue-tantan-stack) A nice slide Component with vue.js. 带有vue.js的漂亮幻灯片组件. View ...

  2. js定义全局变量 vue页面_使用vue.js怎么定义全局变量?

    使用vue.js怎么定义全局变量?下面本篇文章给大家介绍一下在 Vuejs 项目中如何定义全局变量.有一定的参考价值,有需要的朋友可以参考一下,希望对大家有所帮助. 一.在需要的地方引用进全局变量模块 ...

  3. axios vue 回调函数_前端Vue 面试题大全

    点蓝色字关注"程序员报刊" 「  学习 新闻 招聘 」 vue的底层原理? vue组件之间的通信? JS中判断数据类型的方法有几种? 最常见的判断方法:typeof 判断已知对象类 ...

  4. vue 路由重定向_使用Vue和Vue路由器进行高级路由:重定向和Nav Guard

    vue 路由重定向 While the basics of routing in Vue.js have already been covered, today we'll explore some ...

  5. vue 井号_使用Vue 2制作井字游戏:第1部分

    vue 井号 This tutorial assumes that you have a little prior knowledge of JavaScript and the Vue framew ...

  6. 搭建一个vue小页面(入门vue)

    最近在学习vue框架,找了很久在网上找到下面这篇博客,觉得写得通俗易懂,就是其中有些代码尝试了有一点点的小问题,我猜可能版本不同的问题,造成不同的结果,但框架的思想我是觉得写得很通俗易懂的,供大家共享 ...

  7. 覆盖vue.js样式_使用Vue.js和Cloudinary在化身上覆盖眼镜/面罩

    覆盖vue.js样式 Deep Learning, a subset of machine learning, helps break down tasks in ways that makes al ...

  8. vue filter对象_学习vue源码(3) 手写Vue.directive、Vue.filter、Vue.component方法

    一.Vue.directive Vue.directive(id,[definition]); 1)参数 { string } id{ Function | Object } [ definition ...

  9. vue tree组件_使用Vue 3.0做JSX(TSX)风格的组件开发

    前言 我日常工作都是使用React来做开发,但是我对React一直不是很满意,特别是在推出React Hooks以后. 不可否认React Hooks极大地方便了开发者,但是它又有非常多反直觉的地方, ...

最新文章

  1. c 远程编辑linux文件,makefile - 在远程Linux机器上编译C ++ - “检测到时钟偏差”警告...
  2. android 增删改查 源码_学生信息增删改查小程序案例(springboot服务端)
  3. python正则匹配数字_python 正则匹配字母数字中的任意数字,字母
  4. HTMl5的sessionStorage和localStorage
  5. 现行的web开发框架分析
  6. java hashmap 添加_JAVA—HashMap
  7. 知识点1: 进度条随数据变化,并添加渐变样式
  8. BZOJ 3524: [Poi2014]Couriers【主席树】
  9. 跳槽好几次的经验之谈(优先级)
  10. Get value from agent failed:ZBX_TCP_READ() timed out(亲测)
  11. android firefox x86,Firefox 26桌面版加强安全 移动版支持x86
  12. idea的使用记录一
  13. 机器学习(二)——贝叶斯算法
  14. C#Winform拓展控件之Panel
  15. SPSS学习入门 简介安装
  16. 协调端到端的供应链管理——SCM
  17. 如果报华为网络工程师中级培训班一般学费多少?
  18. flask框架之jinjia2模版语法详解
  19. 学习HTML+CSS有感
  20. Python 强制限定小数点位数

热门文章

  1. macos系统里面,蓝牙鼠标偶尔卡顿,飘的问题
  2. 金仓数据库KingbaseES 插件kdb_date_function
  3. 认真CS☀️增量时间—Time.deltaTime Time.fixedDeltaTime
  4. 《Linux系统运维指南》活动中~~
  5. 常用中外文献检索网站大盘点
  6. dubbo升级至2.7.15后application配置无法生效
  7. 转载:与吸烟者共同生活的人,患肺…
  8. 资源 | 吴恩达斯坦福CS230深度学习课程全套资料放出(附下载)
  9. matlab 卷积求图像梯度,图像的卷积(滤波)运算(一)——图像梯度
  10. RibbonControl