zoukankan      html  css  js  c++  java
  • 019——VUE中v-for与computer结合功能实例讲解

    <!DOCTYPE html>
    <html>
    
    	<head>
    		<meta charset="UTF-8">
    		<title>v-for与computer结合功能实例讲解</title>
    		<script src="vue.js"></script>
    	</head>
    
    	<body>
    		<div id="lantian">
    			<li v-for="v in stus">
    				{{v.name}}--{{v.sex}}
    			</li>
    			{{type}}
    			<input type="radio" v-model="type" value="girl" />女孩
    			<input type="radio" v-model="type" value="boy" />男孩
    		</div>
    
    		<script>
    			var app = new Vue({
    				el: '#lantian',
    				computed: {
    					stus() {
    						if(this.type == 'all') {
    							return this.user;
    						} else {
    							return this.user.filter((v) => {
    								return v.sex == this.type;
    							});
    						}
    					}
    				},
    				data: {
    					type: 'all',
    					user: [{
    							name: '小王',
    							sex: 'boy'
    						},
    						{
    							name: '小明',
    							sex: 'boy'
    						},
    						{
    							name: '小李',
    							sex: 'girl'
    						},
    						{
    							name: '小梅',
    							sex: 'girl'
    						}
    					]
    				}
    			});
    		</script>
    	</body>
    
    </html>
    

      

  • 相关阅读:
    ansible变量
    nginx连接php测试
    redis发布订阅
    堡垒机实例以及数据库操作
    nginx简介,使用
    protobuf
    go NSQ
    go mod
    GIT版本管理工具教程
    linux命令查询网站
  • 原文地址:https://www.cnblogs.com/yiweiyihang/p/8080257.html
Copyright © 2011-2022 走看看