vue.js 动态渲染 v-for

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>vue.js Hello World!</title>
<script type="text/javascript" src="https://cdn.bootcss.com/vue/2.2.2/vue.min.js"></script>
</head>
<body>
<div id="cs">
<select v-model="selected">
<option v-for="option in options" v-bind:value="option.value">
{{ option.text }}
</option>
</select>
<span>Selected: {{ selected }}</span>
</div>
<script type="text/javascript">
new Vue({
el: '#cs',
data: {
selected: 'A',
options: [
{ text: 'One', value: 'A' },
{ text: 'Two', value: 'B' },
{ text: 'Three', value: 'C' }
]
}
})
</script>
</body>
</html>

posted on 2017-07-13 20:01  醉半仙  阅读(596)  评论(0编辑  收藏  举报

导航