当前位置:   article > 正文

vue+element ui中dialog 使用知识点记录_vue elementui dialog

vue elementui dialog

搬运工为下次搬运做记录!!!

1、给dialog增加class

<el-dialog

        custom-class="customDialog"

></el-dialog>

2、动态改变dialog宽度

this.$nextTick(() => {

    let dialogBox = document.getElementsByClassName('customDialog')

    for (let i = 0; i < dialogBox.length; i++) {

      dialogBox[i].style.width = '680px';

    }

  })

3、改变弹框进入时动画

.dialog-fade-enter-active .el-dialog.customDialog{

    animation: anim-open ease-in .3s;

  }

  @keyframes anim-open{0%{opacity:0;transform:scale(0.5,1);transform-origin: left top;}to{opacity:1;transform:scale(1,1);transform-origin: left top;}}

4、再次封装弹框

父组件调用

  1. <my-dialog :visible.sync="openFlag">
  2. <FormItem/>
  3. </my-dialog>
  4. //再次编辑的弹框组件
  5. import MyDialog from './components/myDialog.vue'
  6. import FormItem from './components/formItem.vue'
  7. export default {
  8. data() {
  9. return {
  10. // 是否显示弹出层
  11. openFlag: false
  12. }
  13. }
  14. }

子组件-弹框组件(MyDialog )

靠右边的弹框

  1. <template>
  2. <div>
  3. <el-dialog
  4. width="100%"
  5. :visible.sync="visible"
  6. class="my-dialog"
  7. destroy-on-close
  8. @close="myClose"
  9. :show-close="false">
  10. <slot></slot>
  11. </el-dialog>
  12. </div>
  13. </template>
  14. <script>
  15. export default {
  16. name: 'myDialog',
  17. components: {
  18. },
  19. props: {
  20. visible:{
  21. type: Boolean,
  22. default: false
  23. }
  24. },
  25. methods: {
  26. myClose(){
  27. this.$emit('update:visible', false)
  28. }
  29. }
  30. }
  31. </script>
  32. <style lang="scss" scoped>
  33. .my-dialog{
  34. margin-left:70%;
  35. }
  36. ::v-deep .el-dialog{
  37. margin-top: 0 !important;
  38. max-height: calc(100%);
  39. max-width: calc(100%);
  40. .el-dialog__header{display:none;}
  41. .el-dialog__body{padding:0 5%;}
  42. }
  43. </style>

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/weixin_40725706/article/detail/91028
推荐阅读