UNPKG

@antmjs/vantui

Version:

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

68 lines (67 loc) 2.19 kB
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator"; import _regeneratorRuntime from "@babel/runtime/regenerator"; /* eslint-disable */ import { View } from '@tarojs/components'; import { Button } from '@antmjs/vantui'; import { jsx as _jsx } from "react/jsx-runtime"; import { jsxs as _jsxs } from "react/jsx-runtime"; Button.config({ asyncLoading: true // click异步事件触发loading状态手动开启 }); export default function Demo() { // 点击事件返回Promise,即可让按钮自带loading状态 var handle = /*#__PURE__*/function () { var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() { return _regeneratorRuntime.wrap(function _callee$(_context) { while (1) switch (_context.prev = _context.next) { case 0: _context.next = 2; return timeout(); case 2: case "end": return _context.stop(); } }, _callee); })); return function handle() { return _ref.apply(this, arguments); }; }(); return /*#__PURE__*/_jsxs(View, { children: [/*#__PURE__*/_jsx(Button, { type: "default", children: "\u9ED8\u8BA4\u6309\u94AE" }), /*#__PURE__*/_jsx(Button, { type: "primary", children: "\u4E3B\u8981\u6309\u94AE" }), /*#__PURE__*/_jsx(Button, { type: "info", children: "\u4FE1\u606F\u6309\u94AE" }), /*#__PURE__*/_jsx(Button, { type: "warning", children: "\u8B66\u544A\u6309\u94AE" }), /*#__PURE__*/_jsx(Button, { type: "danger", children: "\u5371\u9669\u6309\u94AE" }), /*#__PURE__*/_jsx(View, {}), /*#__PURE__*/_jsx(Button, { type: "info", onClick: handle, loadingText: "\u63D0\u4EA4\u4E2D...", children: "\u786E\u8BA4\u63D0\u4EA4" }), /*#__PURE__*/_jsx(Button, { type: "primary", onClick: handle, loadingMode: "toast", loadingText: "\u63D0\u4EA4\u4E2D...", loadingType: "spinner", children: "\u786E\u8BA4\u63D0\u4EA4" })] }); } function timeout() { return new Promise(function (resolve) { setTimeout(function () { resolve(1); }, 3000); }); }