visibility.uvue 699 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <template>
  2. <view style="flex-grow: 1;">
  3. <view @click="changeVisibility">
  4. <text>visibility: {{visibility}}(点击切换)</text>
  5. <view class="common" :style="{'visibility': visibility}"></view>
  6. </view>
  7. </view>
  8. </template>
  9. <script>
  10. export default {
  11. data() {
  12. return {
  13. visibility: 'visible',
  14. flag: true
  15. }
  16. },
  17. methods: {
  18. changeVisibility() {
  19. this.flag = !this.flag;
  20. if (this.flag) {
  21. this.visibility = 'visible';
  22. } else {
  23. this.visibility = 'hidden';
  24. }
  25. }
  26. }
  27. }
  28. </script>
  29. <style>
  30. .common {
  31. width: 250px;
  32. height: 250px;
  33. background-color: red;
  34. }
  35. </style>