captain-ui
Version:
有赞vue wap业务组件库
81 lines (76 loc) • 1.97 kB
JavaScript
import "vant/es/sidebar-item/style";
import _SidebarItem from "vant/es/sidebar-item";
import "vant/es/sidebar/style";
import _Sidebar from "vant/es/sidebar";
var _components;
import { NAV_STATE } from '../constants';
export default {
render: function render() {
var _vm = this;
var _h = _vm.$createElement;
var _c = _vm._self._c || _h;
return _c('van-sidebar', {
staticClass: "cap-category-nav",
style: _vm.positionStyle,
attrs: {
"active-key": _vm.active
}
}, _vm._l(_vm.navList, function (nav, index) {
return _c('van-sidebar-item', {
key: index,
ref: "badges",
refInFor: true,
staticClass: "cap-category-nav__item",
attrs: {
"title": nav.title
},
on: {
"click": function click($event) {
_vm.handleClick(index);
}
}
});
}), 1);
},
name: 'cap-category-nav',
components: (_components = {}, _components[_Sidebar.name] = _Sidebar, _components[_SidebarItem.name] = _SidebarItem, _components),
props: {
navList: {
type: Array,
default: function _default() {
return [];
}
},
active: {
type: Number,
default: 0
},
state: String,
windowHeight: Number
},
data: function data() {
return {
currentActive: this.active
};
},
computed: {
positionStyle: function positionStyle() {
var position = this.state === NAV_STATE.FIXED ? 'fixed' : '';
var bottom = this.state === NAV_STATE.SCROLL_OUT ? 0 : '';
var top = this.state !== NAV_STATE.SCROLL_OUT ? '' : 'auto';
var maxHeight = this.windowHeight + 'px';
return {
position: position,
top: top,
bottom: bottom,
maxHeight: maxHeight
};
}
},
methods: {
handleClick: function handleClick(index) {
this.currentActive = index;
this.$emit('click', index);
}
}
};