对话框/Tips

vintage-popup 模态窗口jQuery插件

阿里云

使用方法

在页面中直接引入。

也想出现在这里?联系我们
创客主机

HTML 结构

一个模态窗口的基本 HTML 结构如下:

  1. <!-- Button which triggers modal -->
  2. <button type="button" data-popup-target="example">
  3.   Default popup
  4. </button>
  5.  
  6. <!-- Popup -->
  7. <div class="popup" data-popup-id="example" tabindex="-1" role="dialog">
  8.     <div class="popup__container">
  9.         <div class="popup__close"><span></span><span></span></div>
  10.         <div class="popup__content">
  11.             <div class="popup__title">Popup title</div>
  12.             <div class="popup__body">Popup body</div>
  13.         </div>
  14.     </div>
  15. </div>

使用远程异步数据:

  1. <!-- Button that triggers modal -->
  2. <button type="button" data-popup-target="exampleRemote" data-popup-remote="/path/example.json">
  3.   Remote popup
  4. </button>
  5.  
  6. <!-- Popup -->
  7. <div class="popup" data-popup-id="exampleRemote" tabindex="-1" role="dialog">
  8.     <div class="popup__container">
  9.         <div class="popup__close"><span></span><span></span></div>
  10.         <div class="popup__content"></div>
  11.     </div>
  12. </div>

example.json

  1. {
  2.   "replaces": [
  3.     {
  4.       "what": "[data-popup-id='exampleRemote'] .popup__content",
  5.       "data": "<div class="popup__content"><div class="popup__title">Popup title</div><div class="popup__body">Popup body</div></div>"
  6.     }
  7.   ]
  8. }

初始化插件

  1. // initialize popup
  2. $('button').popup();
  3.  
  4. // initialize with options
  5. $('button').popup({
  6.   closeOnEsc: false
  7. });

在 webpack 中使用:

  1. // import popup module
  2. import Popup from 'vintage-popup';
  3.  
  4. // fix jQuery conflict (once)
  5. Popup.expose($);
  6.  
  7. // use it!
  8. $('button').popup();

该 jQuery 模态窗口插件的配置参数请参考:https://github.com/Inspired-by-Boredom/vintage-popup#options
Github 网址:https://github.com/Inspired-by-Boredom/vintage-popup

vintage-popup 模态窗口 jQuery 插件

已有 476 人购买
  • lwfr
查看演示升级 VIP立刻购买

演示地址 下载地址
收藏
(0)

发表回复

热销模板

Ashade - 作品展示摄影相册WordPress汉化主题
LensNews

本站承接 WordPress / PbootCMS / DedeCMS 等
系统建站、仿站、开发、定制等业务!