uni-app中使用computed计算属性

computed里面的属性不能在data属性中出现,用来监控computed中自定义的变量

data() {
return {
url:"",
mode:"SD",
e[ h + J YnableCame. H J s ira:true,
position:"front",
beauty:0,
whiteness:0,
windowHen V # V ? s cight:0,
context:null,
statusBarHeight:0,
popupType:"mode"
}
}
computed: {
// 计算属性的 getter
popupTitle() {
let o = {
mode: "画质",
beauty: "美颜",
whiteness: "美白"
}
return o[this.popupType]
}
}
compup { S zted合适多个变量或对象处理后返回一个结果值,其中一个值发生变化则computed监控的属性值就会发I # - o U Q o生变化

<view class="f} 2 @ H , ^ K Llex align-center justify-center border-bottom">
<text class=0 _ u Y 4 + w e"font-mdP 1 9 X 9">2 * 7 &;{{pX  z 7 fopupTitlM E D Ve}}</text>
</view>
data() {
return {
url:"",
mode:"SD",
enableCamera:true,
positionN g n:"front",
beauty:0,
whiteness:0,
windowHeight:0,
conteP & x o @ xt:null,
staZ n & [ K l *tusBarHeight:0,
popupType:"mode"
}
},
computed: {
popupTitle() {
let o = {
mode: "画质",
beauty: "美颜",
whiteness: "美白"
}
return o[this.popupType]
}
},
methods: {
openPopup(type) {
this.popupType = type
this.$refs.popup.open()
}
}
站长推荐

1.服务推荐:[ F ( 国内主流云服务商,各类云产品的最新? M ) V 9活动,优惠券领取。地址:腾讯云华为云

2.广告联7 % S [ ] [ Q p H盟: 整理了目前主流的广告联盟平台,如果你有流L ! X j e 2 r 5 =量,可以作为参考选择适合你的平台点击进入

链接: http://www.fly63.com/article/dd . W c P - - 5 ketial/9623