UNPKG

@antmjs/vantui

Version:

一套适用于Taro3及React的vantui组件库

51 lines 1.68 kB
import _slicedToArray from "@babel/runtime/helpers/slicedToArray"; /* eslint-disable */ import react from 'react'; import { View } from '@tarojs/components'; import { Cell, Calendar } from '@antmjs/vantui'; import { jsx as _jsx } from "react/jsx-runtime"; import { jsxs as _jsxs } from "react/jsx-runtime"; export default function Demo() { var _react$useState = react.useState(false), _react$useState2 = _slicedToArray(_react$useState, 2), show = _react$useState2[0], setShow = _react$useState2[1]; var _react$useState3 = react.useState(), _react$useState4 = _slicedToArray(_react$useState3, 2), date = _react$useState4[0], setDate = _react$useState4[1]; // @ts-ignore var formatDates = react.useCallback(function (d) { if (d && d.length) { var text = []; d.forEach(function (item) { var res = new Date(item); text.push("".concat(res.getMonth(), "-").concat(res.getDate())); }); return text.join(" \u81F3 "); } }, []); return /*#__PURE__*/_jsxs(View, { children: [/*#__PURE__*/_jsx(Cell, { title: "\u9009\u62E9\u591A\u4E2A\u65E5\u671F", value: formatDates(date), onClick: function onClick() { return setShow(true); } }), /*#__PURE__*/_jsx(Calendar, { show: show, type: "range", onClose: function onClose() { return setShow(false); }, onConfirm: function onConfirm(e) { if (Array.isArray(e.detail.value)) { setDate(e.detail.value.map(function (date) { return date === null || date === void 0 ? void 0 : date.valueOf(); })); setShow(false); } } })] }); }