@antmjs/vantui
Version:
一套适用于Taro3及React的vantui组件库
60 lines • 2.01 kB
JavaScript
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];
var formatDate = react.useCallback(function (d) {
var res = new Date(d);
return d ? "".concat(res.getFullYear(), "-").concat(res.getMonth() + 1, "-").concat(res.getDate()) : '';
}, []);
return /*#__PURE__*/_jsxs(View, {
children: [/*#__PURE__*/_jsx(Cell, {
title: "\u81EA\u5B9A\u4E49\u65E5\u671F\u6587\u6848",
value: formatDate(date),
onClick: function onClick() {
return setShow(true);
}
}), /*#__PURE__*/_jsx(Calendar, {
show: show,
onClose: function onClose() {
return setShow(false);
},
onConfirm: function onConfirm(e) {
if (!Array.isArray(e.detail.value)) {
setDate(e.detail.value.valueOf());
setShow(false);
}
},
formatter: function formatter(day) {
var month = day.date.getMonth() + 1;
var date = day.date.getDate();
if (month === 5) {
if (date === 1) {
day.topInfo = /*#__PURE__*/_jsx(View, {
style: {
color: 'green'
},
children: "\u52B3\u52A8\u8282"
});
} else if (date === 4) {
day.topInfo = '54青年节';
} else if (date === 11) {
day.text = '今天';
}
}
return day;
}
})]
});
}