网络编程 
首页 > 网络编程 > 浏览文章

weui框架实现上传、预览和删除图片功能代码

(编辑:jimmy 日期: 2024/11/20 浏览:3 次 )

jQuery WeUI 是专为微信公众账号开发而设计的一个简洁而强大的UI库,包含全部WeUI官方的CSS组件,并且额外提供了大量的拓展组件,丰富的组件库可以极大减少前端开发时间。

jQuery WeUI 的最大特点是它只提供UI组件,并不会对项目所使用的框架和其他库有任何的限制,几乎可以在任何环境下使用。无论你的项目是基于jQuery,还是 React, Angular, Vue, 你都会发现 jQuery WeUI 能非常方便的和他们结合使用。既是你的项目是一个有很悠久历史的老项目,也几乎可以做到拿来即用。

weui框架暂时只有css文件,并没有js文件实现其功能,我在其html+css后面增加了js实现其功能,为大家提供方便,也为自己保存记录。

<!doctype html>
<html>
  <head>
    <meta charset="UTF-8">
    <title></title>
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <link href="../css/mui.min.css" rel="external nofollow" rel="stylesheet" />
    <link rel="stylesheet" href="weui.min.css" rel="external nofollow" rel="external nofollow" />
    <link rel="stylesheet" href="jquery-weui.css" rel="external nofollow" rel="external nofollow" />
  </head>
  <body>
    <div class="weui-gallery" id="gallery">
      <span class="weui-gallery__img" id="galleryImg"></span>
      <div class="weui-gallery__opr">
        <a href="javascript:" rel="external nofollow" class="weui-gallery__del">
          <i class="weui-icon-delete weui-icon_gallery-delete"></i>
        </a>
      </div>
    </div>
    <div class="weui-cells weui-cells_form">
      <div class="weui-cell">
        <div class="weui-cell__bd">
          <div class="weui-uploader">
            <div class="weui-uploader__hd">
              <p class="weui-uploader__title">图片上传</p>
              <div class="weui-uploader__info">0/2</div>
            </div>
            <div class="weui-uploader__bd">
              <ul class="weui-uploader__files" id="uploaderFiles">
                <li class="weui-uploader__file" style="background-image:url(../images/applogo180x180.png)"></li>
                <li class="weui-uploader__file" style="background-image:url(../images/applogo180x180.png)"></li>
                <li class="weui-uploader__file" style="background-image:url(../images/applogo180x180.png)"></li>
                <li class="weui-uploader__file weui-uploader__file_status" style="background-image:url(../images/applogo180x180.png)">
                  <div class="weui-uploader__file-content">
                    <i class="weui-icon-warn"></i>
                  </div>
                </li>
                <li class="weui-uploader__file weui-uploader__file_status" style="background-image:url(../images/applogo180x180.png)">
                  <div class="weui-uploader__file-content">50%</div>
                </li>
              </ul>
              <div class="weui-uploader__input-box">
                <input id="uploaderInput" class="weui-uploader__input zjxfjs_file" type="file" accept="image/*" multiple="">
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <script src="/UploadFiles/2021-04-02/mui.min.js">

补充说明上述代码中引用以下的这四个文件可以到http://jqweui.com这个weui的官网去下载

<link rel="stylesheet" href="weui.min.css" rel="external nofollow" rel="external nofollow" />
 <link rel="stylesheet" href="jquery-weui.css" rel="external nofollow" rel="external nofollow" />
 <script type="text/javascript" src="/UploadFiles/2021-04-02/jquery-2.1.4.js">

总结

以上所述是小编给大家介绍的weui框架实现上传、预览和删除图片功能代码,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对网站的支持!

上一篇:JS实现电商放大镜效果
下一篇:jQuery Datatable 多个查询条件自定义提交事件(推荐)