rate.nvue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <template>
  2. <view>
  3. <text class="example-info">评分组件多用于商品评价打分、服务态度评价、用户满意度等场景。</text>
  4. <uni-section title="基本用法" type="line"></uni-section>
  5. <view class="example-body">
  6. <uni-rate v-model="rateValue" @change="onChange" />
  7. </view>
  8. <uni-section title="不支持滑动手势选择评分" type="line"></uni-section>
  9. <view class="example-body">
  10. <uni-rate :touchable="false" :value="5" @change="onChange" />
  11. </view>
  12. <uni-section title="设置尺寸大小" type="line"></uni-section>
  13. <view class="example-body">
  14. <uni-rate :size="18" :value="5" />
  15. </view>
  16. <uni-section title="设置评分数" type="line"></uni-section>
  17. <view class="example-body">
  18. <uni-rate :max="10" :value="5" />
  19. </view>
  20. <uni-section title="设置星星间隔" type="line"></uni-section>
  21. <view class="example-body">
  22. <uni-rate :value="4" :margin="20" />
  23. </view>
  24. <uni-section title="设置颜色" type="line"></uni-section>
  25. <view class="example-body">
  26. <uni-rate :value="3" color="#bbb" active-color="red" />
  27. </view>
  28. <uni-section title="半星" type="line"></uni-section>
  29. <view class="example-body">
  30. <uni-rate allow-half :value="3.5" />
  31. </view>
  32. <uni-section title="只读状态" type="line"></uni-section>
  33. <view class="example-body">
  34. <uni-rate :readonly="true" :value="2" />
  35. </view>
  36. <uni-section title="禁用状态" type="line"></uni-section>
  37. <view class="example-body">
  38. <uni-rate :disabled="true" disabledColor="#ccc" :value="3" />
  39. </view>
  40. <uni-section title="未选中的星星为镂空状态" type="line"></uni-section>
  41. <view class="example-body">
  42. <uni-rate :value="3" :is-fill="false" />
  43. </view>
  44. </view>
  45. </template>
  46. <script>
  47. export default {
  48. components: {},
  49. data() {
  50. return {
  51. rateValue: 0
  52. }
  53. },
  54. onLoad() {
  55. // 模拟动态赋值
  56. setTimeout(() => {
  57. this.rateValue = 3
  58. }, 1000)
  59. },
  60. methods: {
  61. onChange(e) {
  62. console.log('rate发生改变:' + JSON.stringify(e))
  63. // console.log(this.rateValue);
  64. }
  65. }
  66. }
  67. </script>
  68. <style>
  69. @charset "UTF-8";
  70. /* 头条小程序组件内不能引入字体 */
  71. /* #ifdef MP-TOUTIAO */
  72. @font-face {
  73. font-family: uniicons;
  74. font-weight: normal;
  75. font-style: normal;
  76. src: url("~@/static/uni.ttf") format("truetype");
  77. }
  78. /* #endif */
  79. /* #ifndef APP-NVUE */
  80. page {
  81. display: flex;
  82. flex-direction: column;
  83. box-sizing: border-box;
  84. background-color: #efeff4;
  85. min-height: 100%;
  86. height: auto;
  87. }
  88. view {
  89. font-size: 14px;
  90. line-height: inherit;
  91. }
  92. .example {
  93. padding: 0 15px 15px;
  94. }
  95. .example-info {
  96. padding: 15px;
  97. color: #3b4144;
  98. background: #ffffff;
  99. }
  100. .example-body {
  101. /* #ifndef APP-NVUE */
  102. display: flex;
  103. /* #endif */
  104. flex-direction: row;
  105. flex-wrap: wrap;
  106. justify-content: center;
  107. padding: 0;
  108. font-size: 14px;
  109. background-color: #ffffff;
  110. }
  111. /* #endif */
  112. .example {
  113. padding: 0 15px;
  114. }
  115. .example-info {
  116. /* #ifndef APP-NVUE */
  117. display: block;
  118. /* #endif */
  119. padding: 15px;
  120. color: #3b4144;
  121. background-color: #ffffff;
  122. font-size: 14px;
  123. line-height: 20px;
  124. }
  125. .example-info-text {
  126. font-size: 14px;
  127. line-height: 20px;
  128. color: #3b4144;
  129. }
  130. .example-body {
  131. flex-direction: column;
  132. padding: 15px;
  133. background-color: #ffffff;
  134. }
  135. .word-btn-white {
  136. font-size: 18px;
  137. color: #FFFFFF;
  138. }
  139. .word-btn {
  140. /* #ifndef APP-NVUE */
  141. display: flex;
  142. /* #endif */
  143. flex-direction: row;
  144. align-items: center;
  145. justify-content: center;
  146. border-radius: 6px;
  147. height: 48px;
  148. margin: 15px;
  149. background-color: #007AFF;
  150. }
  151. .word-btn--hover {
  152. background-color: #4ca2ff;
  153. }
  154. </style>