v-bind 实例

2018-04-27  本文已影响0人  琪33
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>v-bind 实例</title>
    <script type="text/javascript" src="../assets/js/vue.js"></script>
</head>
<body>
    <h1>v-bind 实例</h1>
    <hr>
    <div id="app">
        <p><img v-bind:src="imgSrc"/></p>
        <p><a:href="webUrl" target="_blank">技术</a></p>
        <hr>
        <div :class="className">1.绑定class</div>
        <div :class="{classA:isOk}">2.绑定class中的判断</div>
        <div :class="[classA,classB]">2.绑定class中的数组</div>
        <div :class="isOK?classA:classB">2.绑定class中的三元运算符</div>
        <hr>
        <div>
            <input type="checkbox" id="isOk" v-model="isOK">
            <label for="isOK">isOk={{isOK}}</label>
        </div>
        <hr>
        <div:style="{color:red,fontSize:font}">5.绑定Style</div>
        <div:style="styleObject">6.对象绑定Style</div>

    </div>
    <style>
        .classA {
            color: red;
        }
        .classB {
            font-size: 150%;
        }
    </style>
    
    <script type="text/javascript">
        var app = new Vue({
            el:'#app',
            data:{
                imgSrc:'01.jpg',
                webUrl:'www.baidu.com',
                className:'classA',
                isOk:true,
                classA:'classA',
                classB:'classB',
                red:'red',
                font:'20px',
                styleObject:{
                    color:'green',
                    fontSize:'24px'

                }
            }
        })
    </script>
    
</body>
</html>
上一篇下一篇

猜你喜欢

热点阅读