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>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值