使用element-ui二次封装一个可复用弹窗组件

摘要:
源码链接:弹窗组件组件源码:{{item.label}}exportdefault{props:{that:{type:Object,default:this},modalCfg:{visible:false,title:'',handles:[]},{type:String,default:'50%'},isHeader:{type:Boolean,default:true},modalLoading:{type:Boolean,default:false},isHandle:{type:Boolean,default:true}},computed:{},methods:{close(){this.$emit}}}ViewCode页面调用:因为该组件和其他组件合在一起,这是一个系列˂!

源码链接:弹窗组件

组件源码:

<template>
<transition name="el-fade-in"> 
<div v-if="modalCfg.visible" style="100%;height:100%;position:fixed;top:0px;left:0px;z-index:8;">
    <!-- 遮罩 -->
    <div class="ces-mask"></div>
    <div class="ces-modal-wrap">
      <div   :style="{width}">
        <!-- 标题头部 -->
          <section    v-if="isHeader">
              <div   >
              <div>{{modalCfg.title}}</div>
              <i   @click="modalCfg.close(that)"></i>
              </div>
          </section>
          <!-- body -->
          <section     v-loading="modalLoading">
              <slot></slot>
          </section>
          <!-- 操作底部 -->
          <section   v-if='isHandle'>
              <div class="ces-modal__footer">
              <span>
                <el-button v-for='item in modalCfg.handles' :key="item.label":type='item.type':icon='item.icon':size='item.size':disabled='item.disabled'@click="item.handle(that)">{{item.label}}</el-button>
              </span>
              </div>
          </section>
      </div>
  </div>
</div>
</transition>
</template>

<script>
export default{
  
    props:{
      that: { type: Object, default: this},
      modalCfg:{
        visible:false,
        title:'',
        handles:[]
      },
      {
        type:String,
        default:'50%'},
      isHeader:{
        type:Boolean,
        default:true},
      modalLoading:{
        type:Boolean,
        default:false},
      isHandle:{
        type:Boolean,
        default:true}

    },
    computed: {
        
    },
    methods: {
      close(){
        this.$emit('close')
      }
    }
}
</script>
View Code

页面调用:因为该组件和其他组件合在一起,这是一个系列

<template>
  <div class="ces-main">
    <!-- 搜索 -->
    <ces-search 
      :that='that'size='mini'labelWidth = '50px':searchData = "searchData":searchForm = "searchForm":searchHandle="searchHandle"></ces-search>

    <!-- 操作表格 -->
    <ces-table 
      :that='that'size='mini':isSelection='true':isIndex='true':isPagination='true':isHandle='true':tableData='tableData':tableCols='tableCols':tableHandles='tableHandles':tablePage='tablePage'></ces-table>

    <!-- 弹窗 -->
    <ces-modal width='450px':that='that' :modalCfg='modalCfg'>
        <ces-edit ref='cesEdit' :that='that':editCfg='editForm':editData='editData':editRules='editRules' ></ces-edit>
      </ces-modal>
  </div>
</template>

<script>import cesSearch from '@/components/common/Form/searchForm'import cesTable from '@/components/common/Table/Table'import cesModal from '@/components/common/Modal/Modal'import cesEdit from '@/components/common/Form/editForm'import { createNamespacedHelpers } from 'vuex'const { mapGetters, mapActions } = createNamespacedHelpers('Base')

export default{
  data () {
    return{
      that:this}
  },
  components:{
    cesTable,
    cesSearch,
    cesModal,
    cesEdit
  },
  computed:{
    ...mapGetters([
      'searchData','searchForm','searchHandle',
      'loading','tableData','tableCols','tableHandles','tablePage',
      'modalCfg',
      'editForm','editData','editRules'])
  },
  methods:{
    ...mapActions(['init','showEditModal','hideEditModal','getData','resetData','validateAdd','confirmDel','validateEdit'])
  }
}
</script>

<style>

</style>

最终效果图:

使用element-ui二次封装一个可复用弹窗组件第1张

免责声明:文章转载自《使用element-ui二次封装一个可复用弹窗组件》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇JMeter并发测试(设置集合点)phpstorm 为静态方法添加提示下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

随便看看

Idea常用插件整合

官方网站:https://plugins.jetbrains.com/plugin/228-sql-query-plugin6.IdeaVim基于IntelliJ的Vim仿真插件。注意:如果打开WebInspector,那么CSS/JavaScript同步和元素高亮显示不起作用“pluginisdebuggingthistab”信息栏的可用性问题官方网站:h...

oracle触发器调试

如果触发器执行成功,不会出现第4个图,不成功,会出现数据调试信息,具体报错位置会定位到。F7单步执行4.出错时,会出现调试数据,双击调试数据,可以复制出来...

开源跳板机jumpserver的安装部署和使用详细教程及踩坑经验

安装篇jumpserver需要依赖于mysql数据库,python开发工具的支持,所以需要安装一系列软件。按照提示进行所有流程的安装,安装完成之后访问http://ip:8000端口即可登录到jumpserver。因为jumpserver会在被管理的后端主机上通过此处指定的管理用户来添加指定的用户和sudo权限:配置sudo授权,用于添加sudo授权。...

开源项目推荐:Qt有关的GitHub/Gitee开源项目

https://www.froglogic.com/windeployqthttps://doc.qt.io/Qt-5/windows部署。htmlhttps://wiki.qt.io/Deploy_an_Application_on_Windowshttps://github.com/lucasg/Dependencieshttp://www.depend...

es6 proxy浅析

代理用于定义用户定义的基本操作行为,如搜索、分配、枚举、函数调用等。代理接受要代理的目标对象和一些包含元操作的对象,为要代理的对象创建“屏障”,拦截所有操作,并将其重定向到用户定义的元操作对象。然而,proxy提供了一种更好的方法来实现类似的私有属性constenablePrivate==˃newProxy(target,{has:(obj,k)=˃(!pr...

layui table 打印表格

例如,layui的表单打印方法是将表单的数据重新组合成新页面,但它只能打印当前页面的内容。仅仅说实话是不够的。我整个上午都找到了一些,并说他们自己换了,但他们并不满意。这没用。我只能打印当前页面的内容。我的想法是编写一个函数,传递显示的列和要打印的数据,然后直接打印。不要胡说八道。直接转到代码。...