vue初探2

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title></title>
		<script src="js/vue.js" type="text/javascript" charset="utf-8"></script>
	</head>

	<body>
		<div id="app">
			<button type="checkbox" @click="toggle()" >{{this.isAllSelects_text}}</button>

			<div v-for="item in alls">
				<input type="checkbox" :value="item" v-model="selects" />{{item}}<br>
			</div>
			<p> {{this.getSelects}} </p>
		</div>
	</body>
	<script type="application/javascript">
		let app = new Vue({
			el: "#app",
			data: {
				alls: ["banana", "orange", "watermelon", "pear", "apple"].sort(),
				selects: [],
				isAllSelects: false,
				isAllSelects_text: "SELECT ALL",
			},
			methods: {
				toggle: function() {
					this.isAllSelects = !this.isAllSelects;
					this.selects = (this.isAllSelects == true ? this.alls : []);
					this.isAllSelects_text = (this.isAllSelects == true ? "NO SELECT" : "SELECT ALL");
				},
			},
			computed: {
				getSelects: function() {
					return this.selects.sort();
				}
			}

		});
	</script>
</html>

pic-1
vue初探2

pic-2
vue初探2

pic-3
vue初探2

上一篇:Python文件管理 | typora写博客的图片管理问题


下一篇:python抓取wallhaven首页壁纸