vue弹出alert_基于 Vue 2.0 实现的移动端弹窗 (Alert, Confirm, Toast)组件.

wc-messagebox

基于 vue 2.0 开发的插件

包含 Alert, Confirm, Toast, Prompt

仿照 iOS 原生UI(样式来源: MUI)

一些想法

刚开始的时候想要用现成的弹窗组件来着, 但是查找一圈没有发现比较合适项目的, 所以才自己开发了一个, 包含 Alert, Comfirm, Toast, Prompt 四种, 并且可以单个引入.

Vue 的组件开发实际上比较简单, 有兴趣的可以看下源码实现, 步骤很清晰.

关于样式的问题, 是直接从 MUI(魅族开发的) 中拿过来的, 仿照 iOS 的效果.

效果图

图是动图... 动不了点一下就好.

Install

npm i wc-messagebox --save

Quick Start

import {Alert, Confirm, Toast} from 'wc-messagebox'

import 'wc-messagebox/style.css'

Vue.use(Alert, options)

Vue.use(Confirm, options)

Vue.use(Toast, options)

Usage

this.$alert(text, options)

options = {

title: '', // 默认无标题

btn: {

text: '',

style: {

'backgroun-color': 'red',

'font-size': '20px',

'color': 'blue'

}

}

}

this.$confirm(text, options)

options = {

title: '', // 默认无标题

yes: {

text: '确定',

style: {}

},

no: {

text: '取消',

style: {}

}

}

this.$toast(text, options);

options = {

position: 'bottom' // 'bottom' | 'center',

duration: '1500'

}

其他

Alert, Confirm 返回的是一个Promise, 以支持链式调用.

this.$confirm(text).then(success).catch(fail)

项目地址

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值