zoukankan      html  css  js  c++  java
  • vue04-components

    components 组件

    //组件
    Vue.component('friend-component', {
    	props : ['friend'],
    	filters:{
    		ageInOneYear(age) {
    	      return age + 1;
    	    },
    	    fullName(value) {
    	      return `${value.last}, ${value.first}`;
    	    }
    	},
    	methods: {
    		incrementAge(friend){
    			friend.age =  friend.age + 1;
    		},
    		decrementAge(friend) {
    	      friend.age = friend.age - 1;
    	    }
    	},
    	template : `<div>
    		<h2>age: {{friend.age}}</h2>
    		<h2>Name: {{friend | fullName}}</h2>
    		<button v-on:click="incrementAge(friend)">+</button>
    		<input v-model="friend.first"/>
    		<input v-model="friend.last"/>
    		<button v-on:click="decrementAge(friend)">-</button>
    	</div>`
    })
    
    const app = new Vue({
    	el : '#app',
    	data : {
    		friends: [
    			{
    				first : 'bobby',
    				last : 'banne',
    				age : 25
    			},
    			{
    				first : 'john',
    				last : 'Baby',
    				age : 25
    			}
    		]
    		
    	},
    	template : `<div>
    		 <friend-component v-for="item in friends" v-bind:friend="item" />
    	</div>`
    })
    
    
  • 相关阅读:
    (一)3、安装jexus
    走向全栈之坑—开始实践
    java Collection.stream操作
    redis常用命令练习
    Spring4
    java数据提交时问题
    常见协议默认端口
    重写equals方法
    redis
    xml
  • 原文地址:https://www.cnblogs.com/caijw/p/8457871.html
Copyright © 2011-2022 走看看