Giter VIP home page Giter VIP logo

modal's Introduction

modal

说明

这是一个手撸的*.vue组件,代码灵感源于我冠宇兄的极简主义,不是通用性的,但可以自己改样式。符合ESLint-airbnb标准。

使用方法

在父组件中传入visible属性直接控制modal显隐,接受自定义方法hide隐藏modal 示例:

    <modal :visible="modalShow" @hide="modalShow = $event">
      <div>这是插槽内容</div>
    </modal>

项目解析

  • 为什么不取名为dialog? --避免冲突,dialog是一个原生HTML5元素,尽管现在支持度不佳
  • 为什么style的样式要包裹在.modal下? --为modal组件的样式创建命名空间,避免与父组件样式的冲突
  • @click.stop是什么操作? --阻止事件冒泡
  • dialog自身没有数据的? --既然要完全由父组件来控制子组件的显隐,当然只需要依托唯一布尔值即可

注意事项

  • 父组件中不应有html元素的class名为modal,否则会引起样式冲突
  • 传入的title不是必须的,但visible是必须的,否则会报错
  • 插槽的内容置于modal的body部分

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.