0
点赞
收藏
分享

微信扫一扫

vue动态修改样式(计算属性computed)

尤克乔乔 2022-01-06 阅读 46

vue动态修改样式

  <template>
  	<div class="main"
    	:style="{ height: arpaHeight }"
  	>
  	<button class="btn" @click="clickArpaHeader()"></button>
 </div>
 </template>
 <script>
export default {
  name: "AisPart",
  data() {
    return {
      showArpa: true,
      showOwnState: true,
      arpaComponentHeight: 742,
    };
  },
  methods: {
    clickArpaHeader() {
      this.showArpa = !this.showArpa;
      this.arpaComponentHeight = 302;
    }
  },
  computed: {
    arpaHeight: function() {
      return this.arpaComponentHeight + "px";
    },
  }
};
</script>

<style>
.main {
  width: 322px;
  height: 742px;
  background: red;
}
.btn{
  width:30px;
  height:20px
  background: green;
}
</style>
举报

相关推荐

0 条评论