Vue v-bind

图片处理

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
    <script src="../js/Vue.js" charset="utf-8"></script>
    <script type="text/javascript">
        window.onload = function () {
            var vm = new Vue({
                el: '#box',
                data: {
                    url:'../img/1.jpg',
                    w100:'100px',
                    t:"这是图片"
                }
            });
        }
    </script>
</head>
<body>
<div id="box">
    <img v-bind:src="url" v-bind:width="w100" v-bind:title="t">
    <img :src="url" :width="w100" :title="t">
</div>
</body>
</html>

v-bind class

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
    <style>
        .red{
            color: red;
        }
        .burlywood{
            background: burlywood;
        }
    </style>
    <script src="../js/Vue.js" charset="utf-8"></script>
    <script type="text/javascript">
        window.onload = function () {
            var vm = new Vue({
                el: '#box',
                data: {
                   red:'red',
                    burlywood:'burlywood'
                }
            });
        }
    </script>
</head>
<body>
<div id="box">
    <p :class="[red,burlywood]">文字颜色</p>
</div>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
    <style>
        .red{
            color: red;
        }
        .burlywood{
            background: burlywood;
        }
    </style>
    <script src="../js/Vue.js" charset="utf-8"></script>
    <script type="text/javascript">
        window.onload = function () {
            var vm = new Vue({
                el: '#box',
                data: {

                }
            });
        }
    </script>
</head>
<body>
<div id="box">
    <p :class="{red:true,burlywood:true}">文字颜色</p>
</div>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
    <style>
        .red{
            color: red;
        }
        .burlywood{
            background: burlywood;
        }
    </style>
    <script src="../js/Vue.js" charset="utf-8"></script>
    <script type="text/javascript">
        window.onload = function () {
            var vm = new Vue({
                el: '#box',
                data: {
                    r:true,
                    b:true
                }
            });
        }
    </script>
</head>
<body>
<div id="box">
    <p :class="{red:r,burlywood:b}">文字颜色</p>
</div>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
    <style>
        .red{
            color: red;
        }
        .burlywood{
            background: burlywood;
        }
    </style>
    <script src="../js/Vue.js" charset="utf-8"></script>
    <script type="text/javascript">
        window.onload = function () {
            var vm = new Vue({
                el: '#box',
                data: {
                    json:{
                        red:true,
                        b:false
                    }
                }
            });
        }
    </script>
</head>
<body>
<div id="box">
    <p :class="json">文字颜色</p>
</div>
</body>
</html>

v-bind style

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
    <script src="../js/Vue.js" charset="utf-8"></script>
    <script type="text/javascript">
        window.onload = function () {
            var vm = new Vue({
                el: '#box',
                data: {
                }
            });
        }
    </script>
</head>
<body>
<div id="box">
    <p :style="{color:'aqua'}">文字颜色</p>
</div>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
    <script src="../js/Vue.js" charset="utf-8"></script>
    <script type="text/javascript">
        window.onload = function () {
            var vm = new Vue({
                el: '#box',
                data: {
                    c:{color:'aqua'}
                }
            });
        }
    </script>
</head>
<body>
<div id="box">
    <p :style="[c]">文字颜色</p>
</div>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
    <script src="../js/Vue.js" charset="utf-8"></script>
    <script type="text/javascript">
        window.onload = function () {
            var vm = new Vue({
                el: '#box',
                data: {
                    b:{color:'blue'},
                    a:{backgroundColor:'aqua'}
                }
            });
        }
    </script>
</head>
<body>
<div id="box">
    <p :style="[b,a]">文字颜色</p>
</div>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
    <script src="../js/Vue.js" charset="utf-8"></script>
    <script type="text/javascript">
        window.onload = function () {
            var vm = new Vue({
                el: '#box',
                data: {
                    colors:{
                        color:'blue',
                        backgroundColor:'aqua'
                    }
                }
            });
        }
    </script>
</head>
<body>
<div id="box">
    <p :style="colors">文字颜色</p>
</div>
</body>
</html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值