UNPKG

@antmjs/vantui

Version:

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

54 lines 1.83 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() + 1, "-").concat(res.getDate())); }); return text.join(" \u81F3 "); } }, []); return /*#__PURE__*/_jsxs(View, { children: [/*#__PURE__*/_jsx(Cell, { title: "\u81EA\u5B9A\u6309\u94AE\u6587\u5B57", value: formatDates(date), onClick: function onClick() { return setShow(true); } }), /*#__PURE__*/_jsx(Calendar, { confirmText: "\u70B9\u51FB\u786E\u8BA4", minDate: new Date(2010, 0, 1).getTime(), maxDate: new Date(2010, 1, 28).getTime(), 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); } } })] }); }