fav.nvue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <template>
  2. <view class="example-fav">
  3. <uni-section title="基本用法" type="line"></uni-section>
  4. <view class="example-body example-body-first">
  5. <uni-fav :checked="checkList[0]" class="favBtn" @click="favClick(0)" />
  6. <uni-fav :checked="checkList[1]" :star="false" class="favBtn" @click="favClick(1)" />
  7. <uni-fav :checked="checkList[2]" class="favBtn" :circle="true" bg-color="#dd524d" bg-color-checked="#007aff" fg-color="#ffffff" fg-color-checked="#ffffff" @click="favClick(2)" />
  8. <uni-fav :checked="checkList[3]" class="favBtn" bg-color="#f8f8f8" bg-color-checked="#eeeeee" fg-color="#333333" fg-color-checked="#333333" @click="favClick(3)" />
  9. </view>
  10. <uni-section title="自定义文字" type="line"></uni-section>
  11. <view class="example-body">
  12. <uni-fav :checked="checkList[4]" :content-text="contentText" class="favBtn" @click="favClick(4)" />
  13. </view>
  14. <uni-section title="在自定义导航栏使用" type="line"></uni-section>
  15. <view class="example-body example-body-fullWidth">
  16. <uni-nav-bar style="width: 100%;" :fixed="false" left-icon="arrowleft" title="标题" color="#333333" background-color="#FFFFFF">
  17. <block slot="right">
  18. <uni-fav :checked="checkList[5]" class="favBtn-nav" :circle="true" @click="favClick(5)" />
  19. </block>
  20. </uni-nav-bar>
  21. </view>
  22. </view>
  23. </template>
  24. <script>
  25. export default {
  26. components: {},
  27. data() {
  28. return {
  29. checkList: [false, false, false, false, false, false],
  30. contentText: {
  31. contentDefault: '追番',
  32. contentFav: '已追番'
  33. }
  34. }
  35. },
  36. methods: {
  37. favClick(index) {
  38. this.checkList[index] = !this.checkList[index]
  39. this.$forceUpdate()
  40. }
  41. }
  42. }
  43. </script>
  44. <style>
  45. @charset "UTF-8";
  46. /* 头条小程序组件内不能引入字体 */
  47. /* #ifdef MP-TOUTIAO */
  48. @font-face {
  49. font-family: uniicons;
  50. font-weight: normal;
  51. font-style: normal;
  52. src: url("~@/static/uni.ttf") format("truetype");
  53. }
  54. /* #endif */
  55. /* #ifndef APP-NVUE */
  56. page {
  57. display: flex;
  58. flex-direction: column;
  59. box-sizing: border-box;
  60. background-color: #efeff4;
  61. min-height: 100%;
  62. height: auto;
  63. }
  64. view {
  65. font-size: 14px;
  66. line-height: inherit;
  67. }
  68. .example {
  69. padding: 0 15px 15px;
  70. }
  71. .example-info {
  72. padding: 15px;
  73. color: #3b4144;
  74. background: #ffffff;
  75. }
  76. .example-body {
  77. /* #ifndef APP-NVUE */
  78. display: flex;
  79. /* #endif */
  80. flex-direction: row;
  81. flex-wrap: wrap;
  82. justify-content: center;
  83. padding: 0;
  84. font-size: 14px;
  85. background-color: #ffffff;
  86. }
  87. /* #endif */
  88. .example {
  89. padding: 0 15px;
  90. }
  91. .example-info {
  92. /* #ifndef APP-NVUE */
  93. display: block;
  94. /* #endif */
  95. padding: 15px;
  96. color: #3b4144;
  97. background-color: #ffffff;
  98. font-size: 14px;
  99. line-height: 20px;
  100. }
  101. .example-info-text {
  102. font-size: 14px;
  103. line-height: 20px;
  104. color: #3b4144;
  105. }
  106. .example-body {
  107. flex-direction: column;
  108. padding: 15px;
  109. background-color: #ffffff;
  110. }
  111. .word-btn-white {
  112. font-size: 18px;
  113. color: #FFFFFF;
  114. }
  115. .word-btn {
  116. /* #ifndef APP-NVUE */
  117. display: flex;
  118. /* #endif */
  119. flex-direction: row;
  120. align-items: center;
  121. justify-content: center;
  122. border-radius: 6px;
  123. height: 48px;
  124. margin: 15px;
  125. background-color: #007AFF;
  126. }
  127. .word-btn--hover {
  128. background-color: #4ca2ff;
  129. }
  130. /* #ifdef MP-ALIPAY */
  131. .uni-fav {
  132. margin-left: 20rpx;
  133. }
  134. /* #endif */
  135. .favBtn {
  136. margin: 0 20rpx 20rpx 0;
  137. }
  138. .example-body-fullWidth {
  139. padding: 32rpx 0;
  140. }
  141. .example-body-first {
  142. /* #ifndef APP-PLUS-NVUE */
  143. display: flex;
  144. /* #endif */
  145. flex-direction: row;
  146. justify-content: flex-start;
  147. }
  148. </style>