4. v-model结合select使用

v-model结合select使用


<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>v-model结合select使用title>
head>
<body>

<div id="app">
	<h2>单选h2>
	<select v-model="fruit">
		<option value="香蕉">香蕉option>
		<option value="苹果">苹果option>
		<option value="橙子">橙子option>
		<option value="榴莲">榴莲option>
	select>
	<h3>{{ fruit }}h3>

	<h2>多选h2>
	<select v-model="fruits" multiple>
		<option value="香蕉">香蕉option>
		<option value="苹果">苹果option>
		<option value="橙子">橙子option>
		<option value="榴莲">榴莲option>
	select>
	<h3>{{ fruits }}h3>
div>


<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js">script>
<script>
	app = new Vue({
		data:{
			fruit: '苹果',
			fruits: []
		},
	}).$mount('#app')
script>

body>
html>

你可能感兴趣的:(2.,Vue,v-model使用)