Vue-4-屬性

<!DOCTYPE html>
<html lang="en" xmlns:v-bind="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>屬性</title>
    <script src="../js/vue.js"></script>
    <style>
        .red{
            color: red;
        }
        .black{
            background: black;
        }
        .myred{
            color:green;
        }
    </style>
</head>
<body>

<div id="box">
    <img v-bind:src="url" alt="">
    <!--簡寫-->
    <img :src="url" alt="" :width="w">
    <hr>
    <!--css 第一種使用方法-->
    <strong :class="[red,blue]">文字1...</strong>
    <!--css 第二種使用方法-->
    <strong :class="{myred:true}">文字2...</strong>
    <strong :class="{myred:false}">文字3...</strong>
    <strong :class="{myred:false,black:true}">文字3...</strong>
    <strong :class="{myred:false,black:a}">文字3...</strong>
    <hr>
    <!--style-->
    <strong :style="[x,y]">文字4...</strong>
    <strong :style="b">文字4...</strong>
</div>




<script>
    window.onload = function () {
        //屬性
        new Vue({
            el:'#box',
            data:{
                url:'https://www.baidu.com/img/bd_logo1.png',
                w:"100px",
                red:"red",
                blue:"black",
                a:true,
                x:{color:"red"},
                y:{backgroundColor:"black"},
                b:{color:"red",
                    backgroundColor:"black"
                }
            },
            methods:{
            }
        });
    };
</script>

</body>
</html>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章