viewer.js 显示图片名称和照片属性

 

显示效果:

 

 中间显示照片名称,右侧显示照片属性。

图片名称是保存在数据库里的,照片属性是相机或手机拍照时就存储于照片格式中的。

手机照片甚至保存了经纬度等详细信息(这也是QQ能实现旅游相册的原因)。

 ADO.net MVC   部分视图 ViewPhotoWithAttr,也就是功能模块化。

 

图片名称显示部分代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
imageList: {
  type: Array,
  default: null
}
 
 for (var item of this.imageList) {
    var image = document.createElement('img')
    image.src = item.imageUrlSmall
    image.alt = item.picName; //对alt属性赋值
    imagesEl.appendChild(image)
  }
 
    title: function (img, obj) {  // 这里实现显示图片名称
        return img.getAttribute("alt");
    },

  

在另一个页面中使用,仅用于示意,并非完整代码,实现了iview轮播图上点击后出现viewer大图轮播图。感觉有点重复,但确实有这个需求。

复制代码
    <style>
       .carousel-text{
        position: relative;
        bottom: 25px;
        width: 100%;
        font-size:13px;
         /*width: auto;*/ /*也可以*/ 
        text-align: center;
        color: white;
        background-color: rgba(0,0,0,0.3);
    }
 </style>

                                        <div class="container">
                                            <div id="dowebok_qm">

                                                <Carousel v-bind:radius-dot="carouselDot_qm" dots="outside" v-bind:height="imgHeight2+'px'" v-model="carouselValue_qm" style="text-align:center;">
                                                    <div v-for="item in imgData_qm" v-on:click="handleView_qm(item)">
                                                        <Carousel-Item>
                                                            <img v-bind:src="item.src" style="height:inherit;width:auto;cursor:pointer;" />
                                                            <div><span class="carousel-text"> {{item.textName}}</span></div>
                                                        </Carousel-Item>
                                                    </div>
                                                </Carousel>
                                            </div>

                                        </div>
 <ViewPhotoWithAttr ref="viewerYd_qm" v-bind:image-list="imgData_qm" />

    var vm = new Vue({
        template: "#viewTemplate",
        el: '#app',
        data: {
            imgHeight2:600,
            carouselDot_qm: false,
            carouselValue_qm: 0,
            imgData_qm: [],
         }
        methods: {
            handleView_qm: function (info) { //用于点击时定位
                console.log('handleViewYd', info.id);
                var index = 0
                for (var i = 0; i < this.imgData_qm.length; i++) {
                    if (this.imgData_qm[i].id === info.id) {
                        index = i
                        break
                    }
                }
                console.log('index', index);
                this.$refs.viewerYd_qm.view(index)
            },
   getImageListByID: function (dataID) {
     
    var that=this; //由于ajax中的this不等于vue的this,所以赋值为that; 
 that.imgData_qm = [];
            $.ajax({
                        url: url,
                        type: 'POST',
                        data: { dataID: dataID.toString() },
                        success: function (result) {
                          let imageList = result.rows;
                          var srcPart=“url前缀”;
                          that.imgData_qm.push({ id: imageList[i].ImageID, src: srcPart + imageList[i].ImageID + part, name: imageList[i].FileName, textName: picName, imageUrlSmall: srcPart + imageList[i].ImageID + part, imageUrl: srcPart + imageList[i].ImageID })

             }})
     

   }
 }
})

  
View Code
复制代码

 

相关文章:

1  官方文档: https://github.com/fengyuanchen/viewerjs

 

 

2 viewer 简单用法:

viewer 图片点击放大 用法汇总

https://www.cnblogs.com/hao-1234-1234/p/11011249.html

viewer与 iview Carousel(走马灯) 结合使用,图片无法显示

https://www.cnblogs.com/hao-1234-1234/p/11252183.html

 

posted @   hao_1234_1234  阅读(1872)  评论(0编辑  收藏  举报
编辑推荐:
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具
历史上的今天:
2019-01-09 ABP框架 sql语句(转载)
点击右上角即可分享
微信分享提示