zoukankan      html  css  js  c++  java
  • 练习

    一、1.红黄蓝三个按钮,点击不同的按钮可以切换一个200*200的矩形框对应的颜色

    <!DOCTYPE html>
    <html lang="zh">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
        <style>
            .d1 {
                200px;
                height:200px;
            }
        </style>
    </head>
    <body>
        <div id="app">
            <button style="color: red" @click="changeColourR">红</button>
            <button style="color: yellow" @click="changeColourY">黄</button>
            <button style="color: blue" @click="changeColourB">蓝</button>
            <p :class="c1" :style="color"></p>
        </div>
    </body>
    <script src="js/vue.js"></script>
    <script>
        new Vue({
            el:'#app',
            data:{
                color:{backgroundColor:''},
                c1:'d1'
            },
            methods:{
                changeColourR(){
                    this.color.backgroundColor='red'
                },
                changeColourY(){
                    this.color.backgroundColor='yellow'
                },
                changeColourB(){
                    this.color.backgroundColor='blue'
                },
            }
        })
    </script>
    </html>

    二、 切换颜色

    <!DOCTYPE html>
    <html lang="zh">
    <head>
        <meta charset="UTF-8">
        <title></title>
    </head>
    <body>
        <div id="app">
            <p :class="c1" :style="color" @click="changeColor"></p>
        </div>
    </body>
    <script src="js/vue.js"></script>
    <script>
        new Vue({
            el: '#app',
            data: {
                color:{
                     '100px',
                    height: '100px',
                    backgroundColor: 'red'
                },
            },
            methods:{
                changeColor(){
                    click_num+=1;
                    if(click_num==1){
                        this.color.backgroundColor='pink'
                    }else {
                        if(click_num==2){
                            this.color.backgroundColor='green'
                        }else {
                            if (click_num==3){
                                this.color.backgroundColor='cyan';
                                click_num=0
                            }
                        }
                    }
                }
            }
        })
    </script>
    </html>
  • 相关阅读:
    JSON
    Chromium 修改chrome.exe
    Chromium 修改任务管理器显示的Chromium
    winhttp get请求https
    string wstring 互转
    浏览器指纹在线监测获取网址
    咕了的构造题单总结
    Git 常用命令总结
    C# 网络地址是否有效
    IDEA如何从断点里获取对象所有数据
  • 原文地址:https://www.cnblogs.com/binyuanxiang/p/12052236.html
Copyright © 2011-2022 走看看