最新消息:XAMPP默认安装之后是很不安全的,我们只需要点击左方菜单的 "安全"选项,按照向导操作即可完成安全设置。

vue filter(七)

XAMPP下载 admin 1391浏览 0评论
 使用filter過濾器
const app = new Vue({
el: “#app”,
data: {
friends: [
{
first: “Bobby”,
last: “Boone”,
age: 25
},
{
first: “John”,
last: “Boone”,
age: 35
}
],
},
filters: {
ageInOneYear(age) {
return age + 1;
},
fullName(value) {
return `${value.last}, ${value.first}`;
}
},
methods:{
decrementAge(friend){
friend.age = friend.age – 1;
},
incrementAge(friend){
friend.age = friend.age + 1;
}
},
template: `
<div>
<h2 v-for=”friend in friends”>
<h4>{{friend | fullName}}</h4>
<h5>age: {{friend.age}}</h5>
<button v-on:click=”decrementAge(friend)”>-<tton>
<button v-on:click=”incrementAge(friend)”>+<tton>
<input v-model=”friend.first”>
<input v-model=”friend.last”>
</h2>
</div>
`
})

转载请注明:XAMPP中文组官网 » vue filter(七)

您必须 登录 才能发表评论!