border-style.uvue 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <template>
  2. <!-- #ifdef APP -->
  3. <scroll-view style="flex: 1">
  4. <!-- #endif -->
  5. <view style="flex-grow: 1">
  6. <view>
  7. <text>border-style: dashed</text>
  8. <view class="common" style="border-width: 5px; border-style: dashed"></view>
  9. </view>
  10. <view>
  11. <text>border-left-style: dashed</text>
  12. <view class="common" style="border-left-width: 5px; border-left-style: dashed"></view>
  13. </view>
  14. <view>
  15. <text>border-top-style: dashed</text>
  16. <view class="common" style="border-top-width: 5px; border-top-style: dashed"></view>
  17. </view>
  18. <view>
  19. <text>border-right-style: dotted</text>
  20. <view class="common" style="border-right-width: 5px; border-right-style: dotted"></view>
  21. </view>
  22. <view>
  23. <text>border-bottom-style: dotted</text>
  24. <view class="common" style="border-bottom-width: 5px; border-bottom-style: dotted"></view>
  25. </view>
  26. <view>
  27. <text>border-style: solid (缺省 border-width)</text>
  28. <view class="common" style="border-style: solid;"></view>
  29. </view>
  30. <view>
  31. <text>border-style: none</text>
  32. <view class="common" style="border-style: none; border-width: 5px;"></view>
  33. </view>
  34. <view @click="changeBorderStyle">
  35. <text>border-style: 点击切换</text>
  36. <view class="common" :style="borderStyle"></view>
  37. </view>
  38. </view>
  39. <!-- #ifdef APP -->
  40. </scroll-view>
  41. <!-- #endif -->
  42. </template>
  43. <script>
  44. export default {
  45. data() {
  46. return {
  47. isSolid: false,
  48. borderStyle: "border-style: none; border-width: 5px;",
  49. }
  50. },
  51. methods: {
  52. changeBorderStyle() {
  53. this.isSolid = !this.isSolid;
  54. const solid = "border-style: solid; border-width: 5px;";
  55. const none = "";
  56. this.borderStyle = this.isSolid ? solid : none;
  57. }
  58. }
  59. }
  60. </script>
  61. <style>
  62. .common {
  63. width: 250px;
  64. height: 250px;
  65. background-color: gray;
  66. }
  67. </style>