uniapp计算属性

<template>

<view>

<view>{{getMoney}}</view>

<view v-for="item in filterList" :key="item.id">{{item.name}}</view>

</view>

</template>


<script>

export default {

data(){

return {

title:"2018",

money:10,

list:[

{id:1,name:"张三"},

{id:2,name:"李四"},

{id:3,name:"王五"}

]

}

},

computed:{//uniapp计算属性

getMoney(){

return "¥"+this.money;

},

filterList(){

//只要id小于等于1的

return this.list.filter(v=>v.id<=1);

}

}

}

</script>


<style>

.content{

.sass{

background-color:$uni-color-primary;

}

}


</style>

uniapp计算属性(图1)

您可能还会对下面的文章感兴趣: