1.只读
<template>
<div :style="aa">
{{test}}
</div>
</template>
<script>
export default {
computed: {
test(){
return this.h
}
},
}
2.可修改 通过set
<template>
<div :style="aa">
{{test}}
</div>
</template>
<script>
export default {
methods: {
ck() {
this.test = "已修改” //修改this.h的值
},
computed: {
test:{
get(){
return this.h
},
set(newValue){//修改属性值
this.h= newValue
}
} },
}
网友评论