首页 > 其他分享 >Vue10*10图片表格的点击效果

Vue10*10图片表格的点击效果

时间:2023-03-21 20:46:21浏览次数:42  
标签:10 Vue 表格 img show jpg Vue10 自定义

要求.使用Vue及自定义组件完成10*10图片表格点击效果

效果图

过程:一.用PS切图

1.打开PS,选择切图工具,在左边复选框选择切图工具。

 

 2.单击右键鼠标,选择划分切片。

 

 3.选择水平划分、垂直划分10*10,点击确定。

 

 4.单击菜单栏文件,在导出栏选择储存为Web所用格式。

 

 二.用HBuilder建立Web项目

1.链入Vue.js

 

 2.建立自定义属性"im"

 

 3.动态绑定im=img

 

 4.链入100张图片

 

 5.设置CSS格式

 

 三.源代码如下

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <title></title>
        <script src="js/vue.js"></script>
        <style>
            #app{
                width:1300px;
                height:1740px;
                justify-content:space-around;
                display:flex;
                flex-wrap:wrap;
            }
            .item{
                width:128px;
                height:171px;
                background-color:pink;
            }
        </style>
        <noscript></noscript>
    </head>
    <body>
        <div id="app">
                <!--动态绑定im=img -->
                <ya-img v-for="img in imgs" v-bind:im="img"></ya-img>
        </div>
    </body>
    <template id="test-area">
        <div class="item" @click="change">
            <img :src="im" v-show="show" />
            <!--解析字符串-->
        </div>
    </template>
    <script type="text/javascript">
        //新建组件,注册组件
        Vue.component("ya-img",{
            template:"#test-area",
            props:["im"],//自定义属性
            data:function(){
                return{
                    show:true,
                }
            },
            methods:{
                change:function(){
                    this.show = !this.show;//取反
                }
            }
        });
        var vm = new Vue({
            el:"#app",//作用范围
            data:{
                imgs:["img/img_01.jpg","img/img_02.jpg","img/img_03.jpg","img/img_04.jpg","img/img_05.jpg",
                "img/img_06.jpg","img/img_07.jpg","img/img_08.jpg","img/img_09.jpg","img/img_10.jpg",
                "img/img_11.jpg","img/img_12.jpg","img/img_13.jpg","img/img_14.jpg","img/img_15.jpg",
                "img/img_16.jpg","img/img_17.jpg","img/img_18.jpg","img/img_19.jpg","img/img_20.jpg"
                ,"img/img_21.jpg","img/img_22.jpg","img/img_23.jpg","img/img_24.jpg","img/img_25.jpg",
                "img/img_26.jpg","img/img_27.jpg","img/img_28.jpg","img/img_29.jpg","img/img_30.jpg",
                "img/img_31.jpg","img/img_32.jpg","img/img_33.jpg","img/img_34.jpg","img/img_35.jpg"
                ,"img/img_36.jpg","img/img_37.jpg","img/img_38.jpg","img/img_39.jpg","img/img_40.jpg",
                "img/img_41.jpg","img/img_42.jpg","img/img_43.jpg","img/img_44.jpg","img/img_45.jpg",
                "img/img_46.jpg","img/img_47.jpg","img/img_48.jpg","img/img_49.jpg","img/img_50.jpg",
                "img/img_51.jpg","img/img_52.jpg","img/img_53.jpg","img/img_54.jpg","img/img_55.jpg",
                "img/img_56.jpg","img/img_57.jpg","img/img_58.jpg","img/img_59.jpg","img/img_60.jpg",
                "img/img_61.jpg","img/img_62.jpg","img/img_63.jpg","img/img_64.jpg","img/img_65.jpg",
                "img/img_66.jpg","img/img_67.jpg","img/img_68.jpg","img/img_69.jpg","img/img_70.jpg",
                "img/img_71.jpg","img/img_72.jpg","img/img_73.jpg","img/img_74.jpg","img/img_75.jpg",
                "img/img_76.jpg","img/img_77.jpg","img/img_78.jpg","img/img_79.jpg","img/img_80.jpg",
                "img/img_81.jpg","img/img_82.jpg","img/img_83.jpg","img/img_84.jpg","img/img_85.jpg",
                "img/img_86.jpg","img/img_87.jpg","img/img_88.jpg","img/img_89.jpg","img/img_90.jpg",
                "img/img_91.jpg","img/img_92.jpg","img/img_93.jpg","img/img_94.jpg","img/img_95.jpg",
                "img/img_96.jpg","img/img_97.jpg","img/img_98.jpg","img/img_99.jpg","img/img_100.jpg"
                ]
            }
        });
    </script>
</html>

 

标签:10,Vue,表格,img,show,jpg,Vue10,自定义
From: https://www.cnblogs.com/sweet-fairy/p/17241348.html

相关文章

  • 使用vue完成图片表格的点击因隐藏效果
    首先了解整个项目可以分几个板块。图片的切割,图片放入的框架构建,图片放入。1.图片的分割,这里的图片分割可以使用PS,或者网上搜图片切割的网站上传图片就行(http://www.zuoha......
  • 记录--前端加载超大图片(100M以上)实现秒开解决方案
    这里给大家分享我在网上总结出来的一些知识,希望对大家有所帮助前言前端加载超大图片时,一般可以采取以下措施实现加速:图片压缩:将图片进行压缩可以大幅减小图片的大小,......
  • 10 个顶级开源 API 网关和管理工具
    微服务和API(应用程序编程接口的缩写)在可持续的现代应用程序开发中几乎变得司空见惯。API驱动微服务(一种将应用程序构建为小型、独立且可管理的服务/片段的架构设计),它们定......
  • 523-(ZCU102E的pin兼容替代卡) 基于 XCZU15EG的双 FMC通用信号处理板 高速信号处理、车
    (ZCU102E的pin兼容替代卡)基于XCZU15EG的双FMC通用信号处理板一、板卡概述   本板卡基于XilinxZynqUltrascale+MPSOC系列SOCXCZU15EG-FFVB1156......
  • STM32F103 高级定时器的PWM驱动电机注意事项
    此前一直用通用定时器的PWM驱动电机,因此初始化结构体只有如下几项,今天用TB6612驱动电机,用TIM1-CH4的PWM,结果发现设置完毕后电机不转。//OCInitStructTIM_OC......
  • 刷爆 LeetCode 双周赛 100,单方面宣布第一题最难
    本文已收录到AndroidFamily,技术和职场问题,请关注公众号[彭旭锐]提问。大家好,我是小彭。上周末是LeetCode第100场双周赛,你参加了吗?这场周赛整体没有Hard题,但是......
  • python3.10带openssl
    wgethttps://mirrors.huaweicloud.com/python/3.10.10/Python-3.10.10.tgzwgethttps://www.openssl.org/source/openssl-1.1.1n.tar.gz1.安装openssltar-xfopenssl-1.1.......
  • 100道python基础题——(15)
    题:编写一个程序,计算a+aa+aaa+aaaa的值,给定的数字作为a的值。假设为程序提供了以下输入:9  然后,输出应该是:11106提示:如果输入数据被提供给问题,则应该假定它是控......
  • 100道python基础题——(14)
    题:编写一个接受句子的程序,并计算大写字母和小写字母的数量。假设为程序提供了以下输入:Helloworld!然后,输出应该是:大写实例1小写实例9提示:如果输入数据被提供给问题,则应......
  • 华为OD机试 不含 101 的数
    本期题目:不含101的数......