none.uvue 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <template>
  2. <view class="page" style="flex:1">
  3. <view class="head">
  4. <text class="tip">下面有一个灰色区域,display默认值为none</text>
  5. <text class="tip">当前display值:{{display}}</text>
  6. </view>
  7. <view class="content" :style="{display:display}">
  8. <text style="background-color: aquamarine;">展示display区域</text>
  9. </view>
  10. <button @tap="switchDisplay">切换display属性</button>
  11. </view>
  12. </template>
  13. <script>
  14. export default {
  15. data() {
  16. return {
  17. display: 'none'
  18. }
  19. },
  20. methods: {
  21. switchDisplay() {
  22. this.display = ('flex' == this.display) ? 'none' : 'flex';
  23. }
  24. }
  25. }
  26. </script>
  27. <style>
  28. .page {
  29. align-items: center;
  30. height: 100%;
  31. }
  32. .head {
  33. margin-top: 10px;
  34. margin-bottom: 10px;
  35. align-items: center;
  36. }
  37. .tip {
  38. color: red;
  39. }
  40. .content {
  41. border: 5px solid blue;
  42. margin: 50px 0px;
  43. padding: 50px;
  44. width: 200px;
  45. height: 200px;
  46. background-color: gray;
  47. align-items: center;
  48. justify-content: center;
  49. }
  50. </style>