uni-app中使用computed计算属性
computed里面的属性不能在data属性中出现,用来监控computed中自定义的变量
data() {
return {
url:"",
mode:"SD",
enableCamera:true,
position:"front",
beauty:0,
whiteness:0,
windowHeight:0,
context:null,
statusBarHeight:0,
popupType:"mode"
}
}
computed: {
// 计算属性的 getter
popupTitle() {
let o = {
mode: "画质",
beauty: "美颜",
whiteness: "美白"
}
return o[this.popupType]
}
}<view class="flex align-center justify-center border-bottom" style="height: 90rpx;">
<text class="font-md">{{popupTitle}}</text>
</view>
data() {
return {
url:"",
mode:"SD",
enableCamera:true,
position:"front",
beauty:0,
whiteness:0,
windowHeight:0,
context:null,
statusBarHeight:0,
popupType:"mode"
}
},
computed: {
popupTitle() {
let o = {
mode: "画质",
beauty: "美颜",
whiteness: "美白"
}
return o[this.popupType]
}
},
methods: {
openPopup(type) {
this.popupType = type
this.$refs.popup.open()
}
}本文内容仅供个人学习、研究或参考使用,不构成任何形式的决策建议、专业指导或法律依据。未经授权,禁止任何单位或个人以商业售卖、虚假宣传、侵权传播等非学习研究目的使用本文内容。如需分享或转载,请保留原文来源信息,不得篡改、删减内容或侵犯相关权益。感谢您的理解与支持!