combox.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <template>
  2. <view class="page">
  3. <text class="example-info">组合框一般用于可以选择也可以输入的表单项</text>
  4. <uni-section title="基本用法" type="line"></uni-section>
  5. <view class="example-body">
  6. <uni-combox label="所在城市" :candidates="candidates" placeholder="请选择所在城市" v-model="city"></uni-combox>
  7. <view class="result-box">
  8. <text>所选城市为:{{city}}</text>
  9. </view>
  10. </view>
  11. <uni-section title="设置label宽度" type="line"></uni-section>
  12. <view class="example-body">
  13. <uni-combox label="所在城市" labelWidth="150px" :candidates="candidates" placeholder="请选择所在城市"></uni-combox>
  14. </view>
  15. <uni-section title="设置无匹配项时的提示语" type="line"></uni-section>
  16. <view class="example-body">
  17. <uni-combox label="所在城市" emptyTips="这里啥都没有" placeholder="请选择所在城市"></uni-combox>
  18. </view>
  19. </view>
  20. </template>
  21. <script>
  22. export default {
  23. components: {},
  24. data() {
  25. return {
  26. candidates: ['北京', '南京', '东京', '武汉', '天津', '上海', '海口'],
  27. city: ''
  28. }
  29. },
  30. methods: {
  31. }
  32. }
  33. </script>
  34. <style>
  35. @charset "UTF-8";
  36. /* 头条小程序组件内不能引入字体 */
  37. /* #ifdef MP-TOUTIAO */
  38. @font-face {
  39. font-family: uniicons;
  40. font-weight: normal;
  41. font-style: normal;
  42. src: url("~@/static/uni.ttf") format("truetype");
  43. }
  44. /* #endif */
  45. /* #ifndef APP-NVUE */
  46. page {
  47. display: flex;
  48. flex-direction: column;
  49. box-sizing: border-box;
  50. background-color: #efeff4;
  51. min-height: 100%;
  52. height: auto;
  53. }
  54. view {
  55. font-size: 14px;
  56. line-height: inherit;
  57. }
  58. .example {
  59. padding: 0 15px 15px;
  60. }
  61. .example-info {
  62. padding: 15px;
  63. color: #3b4144;
  64. background: #ffffff;
  65. }
  66. .example-body {
  67. /* #ifndef APP-NVUE */
  68. display: flex;
  69. /* #endif */
  70. flex-direction: row;
  71. flex-wrap: wrap;
  72. justify-content: center;
  73. padding: 0;
  74. font-size: 14px;
  75. background-color: #ffffff;
  76. }
  77. /* #endif */
  78. .example {
  79. padding: 0 15px;
  80. }
  81. .example-info {
  82. /* #ifndef APP-NVUE */
  83. display: block;
  84. /* #endif */
  85. padding: 15px;
  86. color: #3b4144;
  87. background-color: #ffffff;
  88. font-size: 14px;
  89. line-height: 20px;
  90. }
  91. .example-info-text {
  92. font-size: 14px;
  93. line-height: 20px;
  94. color: #3b4144;
  95. }
  96. .example-body {
  97. flex-direction: column;
  98. padding: 15px;
  99. background-color: #ffffff;
  100. }
  101. .word-btn-white {
  102. font-size: 18px;
  103. color: #FFFFFF;
  104. }
  105. .word-btn {
  106. /* #ifndef APP-NVUE */
  107. display: flex;
  108. /* #endif */
  109. flex-direction: row;
  110. align-items: center;
  111. justify-content: center;
  112. border-radius: 6px;
  113. height: 48px;
  114. margin: 15px;
  115. background-color: #007AFF;
  116. }
  117. .word-btn--hover {
  118. background-color: #4ca2ff;
  119. }
  120. .example-body {
  121. padding: 0px 12px;
  122. background-color: #FFFFFF;
  123. }
  124. .result-box {
  125. text-align: center;
  126. padding: 20px 0px;
  127. font-size: 16px;
  128. }
  129. </style>