vue——5-v-bind及其实例

版权声明:转发博客 请注明出处 否则必究 https://blog.csdn.net/lucky541788/article/details/82721538
<div id="enjoy">
    <!--语法结构:v-bind:argument='expression'  缩写形式::argument='expression'-->
    <img v-bind:src="imgSrc1" :title="title1"  width="400">
    <img :src="imgSrc2" :title="title2"  width="400">
    <p :style="{color:fontColor}">{{msg}}</p>
</div>

这里写图片描述

        {
            new Vue({
                el:'#enjoy',
                data:{
                    imgSrc1:"../images/fashion-001.jpg",
                    imgSrc2:"../images/fashion-001.jpg",
                    title1:'lucy',
                    title2:'bob',
                    msg:'hello boy!',
                    fontColor:'red'
                }
            })
        }

实例

这里写图片描述

<div id="enjoy">
    <p v-for="(college,index) in colleges" :class="index === activeIndex ? 'current' : ''">{{college}}</p>
</div>
        {
            new Vue({
                el: '#enjoy',
                data: {
                    colleges: [
                        'html1学院',
                        'html2学院',
                        'html3学院',
                        'html4学院',
                        'html5学院'
                    ],
                    activeIndex:3
                }
            })
        }

猜你喜欢

转载自blog.csdn.net/lucky541788/article/details/82721538