uniapp实现自定义弹窗组件,支持富文本传入内容

1.首先安装vuex 
通过此命令安装 ​​npm install vuex --save​

 创建initModal.js

import Vuex from 'vuex'
// 自定义弹窗
export default function initModal (v) {
  // 挂在store到全局Vue原型上
  v.prototype.$modalStore = new Vuex.Store({
    state: {
      show: false,
      title: '标题',
      content: '内容',
      isRichText: false,
      showCancel: true,
      cancelText: '取消',
      cancelColor: '#333333',
      cancelBackgroundColor: 'rgba(236, 236, 236, 0.39)',
      confirmText: '确定',
      confirmColor: '#333333',
      confirmBackgroundColor: '#FFBB24',
      success: null
    },
    mutations: {
      hideModal (state) {
        // 小程序导航条页面控制
        // #ifndef H5
        if (state.hideTabBar) {
          wx.showTabBar()
        }
        // #endif
        state.show = false
      },
      showModal (state, data) {
        state = Object.assign(state, data)
        console.log(state)
        state.show = true
      },
      success (state, res) {
        let cb = state.success
        let resObj = {
          cancel: false,
          confirm: false
        }
        res == 'confirm' ? (resObj.confirm = true) : (resObj.cancel = true)
        cb &
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值