vue的bind练习

来源:互联网 发布:mac限免 编辑:程序博客网 时间:2024/06/14 10:31
<!DOCTYPE html><html><head><meta charset="UTF-8"><title></title><script type="text/javascript" src="vue.js" ></script></head>    <style type="text/css">    .active{    background-color:orange;    font-size: 20px;    color: #fff;    }    </style><body><div id="app">        <p v-for="(college, index) in colleges" :class="index=== indexActive?'active':''">           {{college}}        </p>           <p :style="{color:fontColor}">今天天气很好</p></div><script type="text/javascript">new Vue({el:'#app',data:{                    colleges:[                    'ios学院','java学院','HTML学院','UI学院','VR学院'],                    indexActive:3,                    fontColor:'red'}})</script></body></html>