• vue实例


    <!--
    需求:
    背景图片,进度条,减和重置按钮
    进度条填满红色,值为100%,点击减时,进度条依次减十,减到0时换一张背景图片,减按钮消失,点击重置按钮时,进度条重新填满红色
    -->
    效果图:

    点击减按钮后:

    进度条减为0后:

    点击重置后:

    源码:

    <!--
    需求:
    背景图片,进度条,减和重置按钮
    进度条填满红色,值为100%,点击减时,进度条依次减十,减到0时换一张背景图片,减按钮消失,点击重置按钮时,进度条重新填满红色
    -->
    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="UTF-8">
    <title>testUI</title>
    <script src="vue/vue.js"></script>
    <style>
    #picture{/*背景图片*/
    background:url("smallPicture.png") no-repeat;
    margin:0 auto;
    250px;
    height:100px;
    }
    #progress{/*进度条框*/
    200px;
    height:30px;
    border:solid 1px black;
    margin:0 auto;
    }
    #progress div{/*进度条内部红色div*/
    100%;
    height:30px;
    background-color: red;
    }
    #button{/*减和重置按钮*/
    100px;
    height:200px;
    margin:0 auto;
    margin-top:30px;
    }
    #picture.burst{/*重新更换的一个背景图片*/
    background:url("black.jpg") no-repeat;
    }
    </style>
    </head>
    <body>
    <div id="vue">
    <div id="picture" v-bind:class="{burst:ended}"></div>
    <div id="progress" >
    <div v-bind:style={score+"%"}></div>
    </div>
    <div id="button">
    <button v-on:click="desc" v-show="!ended">减</button><!--点击依次减10,开始时按钮显示,当进度条红色为0时,ended标为true,减按钮消失-->
    <button v-on:click="restart">重置</button><!--点击重置按钮时,进度条红色重置为100%-->
    </div>
    </div>
    </body>
    </html>

    <script>
    new Vue({
    el: "#vue",
    data: {
    score:100,
    ended:false//用作正确与否作为判断
    },
    methods: {//减方法
    desc:function(){
    this.score-=10;
    if(this.score==0){//如果进度条内部的红色为0了,则将ended的值改为true
    this.ended=true;
    }
    },//重置方法
    restart:function(){
    this.score=100;
    }
    },
    computed: {

    }
    });
    </script>
    
    
  • 相关阅读:
    grad-cam 、cam 和热力图,基于keras的实现
    高斯过程(转)
    Keras中使用LSTM层时设置的units参数是什么
    Real Time Credit Card Fraud Detection with Apache Spark and Event Streaming
    NodeJs+http+fs+request+cheerio 采集,保存数据,并在网页上展示(构建web服务器)
    NodeJs+Request+Cheerio 采集数据
    数组与对象的深浅复制
    Git(进击学习:远程仓库操作)-V3.0
    牛逼的css3:动态过渡与图形变换
    Git(远程仓库:git@oschina)-V2.0
  • 原文地址:https://www.cnblogs.com/MrZWJ/p/10114747.html
Copyright © 2020-2023  润新知