index.vue 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <template>
  2. <div class="btngroup">
  3. <van-button
  4. v-if="weibo && weibo['6m'][type] && weibo['6m'][type].length"
  5. :type="readType === '6m' ? 'info' : 'default'"
  6. @click="() => selectClick('6m')"
  7. size="mini"
  8. >
  9. 1小时
  10. </van-button>
  11. <van-button
  12. v-if="weibo && weibo['24h'][type] && weibo['24h'][type].length"
  13. :type="readType === '24h' ? 'info' : 'default'"
  14. @click="() => selectClick('24h')"
  15. size="mini"
  16. >
  17. 24小时
  18. </van-button>
  19. <van-button
  20. v-if="weibo && weibo['7d'][type] && weibo['7d'][type].length"
  21. :type="readType === '7d' ? 'info' : 'default'"
  22. @click="() => selectClick('7d')"
  23. size="mini"
  24. >
  25. 7天
  26. </van-button>
  27. <van-button
  28. v-if="weibo && weibo['30d'][type] && weibo['30d'][type].length"
  29. :type="readType === '30d' ? 'info' : 'default'"
  30. @click="() => selectClick('30d')"
  31. size="mini"
  32. >
  33. 30天
  34. </van-button>
  35. </div>
  36. </template>
  37. <style scoped>
  38. .btngroup {
  39. float: right;
  40. padding-right: 5px;
  41. display: inline-block;
  42. }
  43. </style>
  44. <script>
  45. import { Button as vanButton } from "vant";
  46. import "vant/lib/button/style";
  47. export default {
  48. components: {
  49. vanButton,
  50. },
  51. props: {
  52. type: {
  53. type: String,
  54. value: "",
  55. },
  56. weibo: {
  57. type: Object,
  58. value: () => {
  59. return {};
  60. },
  61. },
  62. },
  63. data() {
  64. return {
  65. readType: "30d",
  66. };
  67. },
  68. created() {},
  69. methods: {
  70. selectClick(key) {
  71. if (key === this.readType) return;
  72. this.$emit("changeBtn", { key, type: this.type }, () => {
  73. this.readType = key;
  74. });
  75. },
  76. },
  77. };
  78. </script>