zoukankan      html  css  js  c++  java
  • Vue作业

    作业一

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
        <style>
            .b1 {
                 50px;
                height: 50px;
    
                background-color: red;
            }
            .b2 {
                 50px;
                height: 50px;
    
                background-color: yellow;
            }
            .b3 {
                 50px;
                height: 50px;
    
                background-color: blue;
            }
        </style>
    </head>
    <body>
    <div id="d">
        <input type="button" :class="[b1]" @click="c1">
        <input type="button"  :class="[b2]" @click="c2">
        <input type="button"  :class="[b3]" @click="c3">
        <div :style="myStyle" :class="b4"></div>
    </div>
    
    
    
    
    
    </body>
    <script src="js/vue.js"></script>
    <script>
        new Vue({
            el:'#d',
            data:{
                myStyle:{
                    '200px',
                    height:'200px',
                    backgroundColor: 'red'
                },
                b1:'b1',
                b2:'b2',
                b3:'b3',
            },
            methods:{
                c1(){
                    this.myStyle.backgroundColor='red'
                },
                c2(){
                    this.myStyle.backgroundColor='yellow'
                },
                c3(){
                    this.myStyle.backgroundColor='blue'
                },
            }
    
        })
    </script>
    </html>
    

    作业二

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
    
    </head>
    <body>
    
    <div :style="myStyle" class="b4" @click="d1" id="wrap" >{{ msg }}</div>
    
    </body>
    <script src="js/vue.js"></script>
    <script>
        new Vue({
            el:'#wrap',
            data:
                {
                    myStyle:{
                                    '200px',
                                    height:'200px',
                                    backgroundColor: 'red',
                        color:'red'
                                },
                   msg:0
                },
            methods:{
                d1(){
                    this.msg+=1;
                     if (this.msg==1) {
                            this.myStyle.backgroundColor='pink';
                            this.myStyle.color='pink'
                        }else if(this.msg==2){
                            this.myStyle.backgroundColor='green';
                            this.myStyle.color='green'
                     }else if(this.msg==3){
                            this.myStyle.backgroundColor='cyan';
                            this.myStyle.color='cyan'
                     }else {
                         this.msg=0;
                         this.myStyle.backgroundColor='pink';
                         this.myStyle.color='pink'
    
                     }
    
    
    
                }
            }
    
        })
    </script>
    </html>
    
  • 相关阅读:
    【PAT】 B1006 换个格式输出整数
    【PAT】B1014 福尔摩斯的约会
    【PAT】B1005 继续(3n+1)猜想
    【PAT】B1004 成绩排名
    【PAT】B1003 我要通过!
    【PAT】B1002 写出这个数
    【PAT】B1001 害死人不偿命的(3n+1)猜想
    【PAT】A1001A+B Format
    【PAT】B1027 打印沙漏(20 分)
    【PAT】B1032 挖掘机技术哪家强(20 分)
  • 原文地址:https://www.cnblogs.com/kaizi111/p/12052484.html
Copyright © 2011-2022 走看看