sixue-content
Version:
64 lines (58 loc) • 2.11 kB
JavaScript
import _Breadcrumb from "@alifd/next/es/breadcrumb";
import _extends from "@babel/runtime/helpers/extends";
import React, { useEffect, useState } from 'react';
import './index.scss';
export default function SixueContent(props) {
var _others$breadList, _others$tabList;
var others = _extends({}, props);
var _useState = useState(Number),
tabNum = _useState[0],
setTabNum = _useState[1];
useEffect(function () {
setTabNum(others.tabIndex);
}, [others.tabIndex]);
var tab = function tab(index) {
setTabNum(index);
var key = others.tabList[index].key;
if (typeof others.tabFunc === 'function') {
others.tabFunc(key);
}
};
return /*#__PURE__*/React.createElement("div", {
className: "SixueContent"
}, ((_others$breadList = others.breadList) === null || _others$breadList === void 0 ? void 0 : _others$breadList.length) > 0 && /*#__PURE__*/React.createElement(_Breadcrumb, {
id: "SixueBreadcrumb",
className: "SixueBreadcrumb"
}, others.breadList.map(function (item, index) {
return /*#__PURE__*/React.createElement(_Breadcrumb.Item, {
link: item.link,
key: index
}, item.name);
})), ((_others$tabList = others.tabList) === null || _others$tabList === void 0 ? void 0 : _others$tabList.length) > 0 && /*#__PURE__*/React.createElement("ul", {
id: "SixueTab",
className: "SixueTab"
}, others.tabList.map(function (item, index) {
return /*#__PURE__*/React.createElement("li", {
className: tabNum === index ? 'active' : '',
key: index,
onClick: function onClick() {
tab(index);
}
}, item.name);
})), /*#__PURE__*/React.createElement("div", {
className: "SixueScroll"
}, /*#__PURE__*/React.createElement("div", {
className: "scrollNode " + (others.isBackground ? '' : 'backgroundNo'),
style: others.scrollNodeStyle
}, others.children)), /*#__PURE__*/React.createElement("div", {
className: "placeholderF"
}));
}
SixueContent.defaultProps = {
breadList: [],
tabList: [],
tabIndex: 0,
scrollNodeStyle: {},
tabFunc: '',
isBackground: true
};