index.vue 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <template>
  2. <uni-shadow-root class="weapp-lib-sidebar-item-index"><view :class="(utils.bem('sidebar-item', { selected, disabled }))+' '+(selected ? 'active-class' : '')+' '+(disabled ? 'disabled-class' : '')+' custom-class'" hover-class="van-sidebar-item--hover" hover-stay-time="70" @click="onClick">
  3. <view class="van-sidebar-item__text">
  4. <van-info v-if="badge != null || info !== null || dot" :dot="dot" :info="badge != null ? badge : info"></van-info>
  5. <view v-if="title">{{ title }}</view>
  6. <slot v-else name="title"></slot>
  7. </view>
  8. </view></uni-shadow-root>
  9. </template>
  10. <wxs src="../wxs/utils.wxs" module="utils"></wxs>
  11. <script>
  12. import VanInfo from '../info/index.vue'
  13. global['__wxVueOptions'] = {components:{'van-info': VanInfo}}
  14. global['__wxRoute'] = 'weapp/lib/sidebar-item/index'
  15. "use strict";
  16. Object.defineProperty(exports, "__esModule", { value: true });
  17. var component_1 = require("../common/component");
  18. var relation_1 = require("../common/relation");
  19. (0, component_1.VantComponent)({
  20. classes: ['active-class', 'disabled-class'],
  21. relation: (0, relation_1.useParent)('sidebar'),
  22. props: {
  23. dot: Boolean,
  24. badge: null,
  25. info: null,
  26. title: String,
  27. disabled: Boolean,
  28. },
  29. methods: {
  30. onClick: function () {
  31. var _this = this;
  32. var parent = this.parent;
  33. if (!parent || this.data.disabled) {
  34. return;
  35. }
  36. var index = parent.children.indexOf(this);
  37. parent.setActive(index).then(function () {
  38. _this.$emit('click', index);
  39. parent.$emit('change', index);
  40. });
  41. },
  42. setActive: function (selected) {
  43. return this.setData({ selected: selected });
  44. },
  45. },
  46. });
  47. export default global['__wxComponents']['weapp/lib/sidebar-item/index']
  48. </script>
  49. <style platform="mp-weixin">
  50. @import '../common/index.css';.van-sidebar-item{background-color:var(--sidebar-background-color,#f7f8fa);border-left:3px solid transparent;box-sizing:border-box;color:var(--sidebar-text-color,#323233);display:block;font-size:var(--sidebar-font-size,14px);line-height:var(--sidebar-line-height,20px);overflow:hidden;padding:var(--sidebar-padding,20px 12px 20px 8px);-webkit-user-select:none;user-select:none}.van-sidebar-item__text{display:inline-block;position:relative;word-break:break-all}.van-sidebar-item--hover:not(.van-sidebar-item--disabled){background-color:var(--sidebar-active-color,#f2f3f5)}.van-sidebar-item:after{border-bottom-width:1px}.van-sidebar-item--selected{border-color:var(--sidebar-selected-border-color,#ee0a24);color:var(--sidebar-selected-text-color,#323233);font-weight:var(--sidebar-selected-font-weight,500)}.van-sidebar-item--selected:after{border-right-width:1px}.van-sidebar-item--selected,.van-sidebar-item--selected.van-sidebar-item--hover{background-color:var(--sidebar-selected-background-color,#fff)}.van-sidebar-item--disabled{color:var(--sidebar-disabled-text-color,#c8c9cc)}
  51. </style>