All Projects → zxzhgk → showModal

zxzhgk / showModal

Licence: other
适用于uni-app 的跨端显示弹层,使用接口参数与uni-app 中的showModal参数一致

Programming Languages

Vue
7211 projects
CSS
56736 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to showModal

uParse
📰适用于 uni-app/mpvue 的富文本解析自定义组件
Stars: ✭ 45 (-32.84%)
Mutual labels:  mpvue, uni-app
image-cropper
💯一款功能强大的微信小程序图片裁剪插件
Stars: ✭ 1,123 (+1576.12%)
Mutual labels:  mpvue, uni-app
Uni App
uni-app 是使用 Vue 语法开发小程序、H5、App的统一框架
Stars: ✭ 34,949 (+52062.69%)
Mutual labels:  mpvue, uni-app
Mpvue Docs
mpvue docs
Stars: ✭ 91 (+35.82%)
Mutual labels:  mpvue
Mpvue Weui
用 vue 写小程序,基于 mpvue 框架重写 weui。
Stars: ✭ 1,463 (+2083.58%)
Mutual labels:  mpvue
Itmuch Miniapp
IT牧场小程序前端代码,使用mpvue + vant-weapp构建。本项目仅供教学使用,如果前端基础不好的同学,可以直接放弃。不影响Spring Cloud Alibaba的学习。
Stars: ✭ 153 (+128.36%)
Mutual labels:  mpvue
uniapp-huanxin-kefu
uni-app接入android原生环信客服
Stars: ✭ 36 (-46.27%)
Mutual labels:  uni-app
Mpvuesimple Quickstart
mpvue的一个快速搭建脚手架,添加引入原生小程序开发的UI如iview-weapp、wux-weapp等,包含vuex、axios、mp-weui的示例
Stars: ✭ 71 (+5.97%)
Mutual labels:  mpvue
Mpvue Picker
基于 mpvue 框架的小程序选择控件,支持单列,多列,联动。
Stars: ✭ 173 (+158.21%)
Mutual labels:  mpvue
Examples
Stars: ✭ 133 (+98.51%)
Mutual labels:  mpvue
Wx Book
仿追书神器的小说阅读器小程序
Stars: ✭ 122 (+82.09%)
Mutual labels:  mpvue
Mpvue Vuex Demo
用mpvue构建的小程序-vue模板项目,还引入了vuex,sass,flyio等
Stars: ✭ 112 (+67.16%)
Mutual labels:  mpvue
We Cropper
微信小程序图片裁剪工具
Stars: ✭ 1,972 (+2843.28%)
Mutual labels:  mpvue
Wxh5sudoku469
mpvue版 ——H5 和 微信小程序同时开发 数独游戏
Stars: ✭ 103 (+53.73%)
Mutual labels:  mpvue
Meedu Wxapp
📜meEdu微信小程序。(wxapp for meedu)
Stars: ✭ 199 (+197.01%)
Mutual labels:  mpvue
Service Mpvue Mini
基于mpvue的顺风车、约车小程序,目前已上线~~
Stars: ✭ 89 (+32.84%)
Mutual labels:  mpvue
Mp Weui
mp-weui 是基于 mpvue 和 weui-wxss 的微信小程序 UI 库。
Stars: ✭ 167 (+149.25%)
Mutual labels:  mpvue
Mp canvas drawer
🚀 微信小程序上canvas绘制图片助手,一个json就制作分享朋友圈图片
Stars: ✭ 1,611 (+2304.48%)
Mutual labels:  mpvue
Mpvue Ts Demo
A Mpvue demo project with TypeScript. Mpvue搭配TypeScript也是妥妥的。
Stars: ✭ 119 (+77.61%)
Mutual labels:  mpvue
Takeaway
🍰 mpvue Takeaway WeChat Mini Program
Stars: ✭ 141 (+110.45%)
Mutual labels:  mpvue

一个适用于uni-app的跨端显示弹层,接口参数与uni-app 中的showModal参数一致,简单使用方式如下 :

this.$showModal({
  title: '提示',
  content: '这是一个模态弹窗',
  success(res) {
    if (res.confirm) {
      console.log('用户点击确定')
    } else if (res.cancel) {
      console.log('用户点击取消')
    }
  }
})

如果对您有帮助麻烦点个星星 我会持续更新的~ gitHub

注意项

1. 依赖于 vuex 如没有安装请先安装vuex

 如果你没有引入vuex 一个简单的初始化vuex的main.js 内容, 可以参照修改

import Vue from 'vue'
import App from './App'
import Vuex from 'vuex';
Vue.use(Vuex)
Vue.config.productionTip = false

import initModal from "@/components/zhangxu-showModal/initModal.js";
import showModal from '@/components/zhangxu-showModal/show-modal';
initModal(Vue);
Vue.component('show-modal',showModal);

App.mpType = 'app'

const store = new Vuex.Store();
const app = new Vue({
    store,
    ...App
})
app.$mount()

2. 样式使用scss 请安装或修改 样式为你的预处理语言

使用方式

在main.js中

// 注册全局modal组件
import initModal from "@/components/zhangxu-showModal/initModal.js";
import showModal from '@/components/zhangxu-showModal/show-modal';
initModal(Vue);
Vue.component('show-modal',showModal);

在需要的页面中 (注 需要的页面每个都要引入)

<template>
    <div>
        <show-modal></show-modal>
    </div>
</template>

在函数中(注 此组件在main.js 中全局引入不需要在子组件中再注册组件)

this.$showModal({
  title: '提示',
  content: '这是一个模态弹窗',
  success(res) {
    if (res.confirm) {
      console.log('用户点击确定')
    } else if (res.cancel) {
      console.log('用户点击取消')
    }
  }
})

OBJECT参数说明

参数 类型 必填 说明
title String 提示的标题
content String 提示的内容
showCancel Boolean 是否显示取消按钮,默认为 true
cancelText String 取消按钮的文字,默认为"取消",
cancelColor HexColor 取消按钮的文字颜色,默认为"#000000"
confirmText String 确定按钮的文字,默认为"确定",
confirmColor HexColor 确定按钮的文字颜色
success Function 接口调用成功的回调函数
hideTabBar Boolean 是否隐藏tabBar在APP和小程序中隐藏tabBar 可以让遮罩层全屏

success返回参数说明

参数 类型 说明
confirm Boolean 为 true 时,表示用户点击了确定按钮
cancel Boolean 为 true 时,表示用户点击了取消

完整参数如下:

this.$showModal({
	title:"我是标题",
	content:'我内容',
	showCancel:true,
	cancelText:"取消",
	cancelColor:"#000000",
	confirmText:"确定",
	confirmColor:"red",
	hideTabBar:true,
	success:function(res){
		if(res.confirm){
			wx.showToast({
				title: '点击了确定',
				icon: 'none',
				duration: 2000
			})
		}else{
			wx.showToast({
				title: '点击了取消',
				icon: 'none',
				duration: 2000
			})
		}
	},
})

版本更新

20190519:

修改了再不设置title的情况下布局不正常问题

20190527:

1.修改了蒙版阻止滚动,增加页面回退时自动关闭弹窗
2.增加回退页面时关闭弹出层功能

20190918:

1.增加自定义slot示例
2.删除部分不必要代码

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].