UNPKG

@cainiaofe/cn-ui-m

Version:
49 lines (48 loc) 3.26 kB
import { __assign } from "tslib"; import * as React from 'react'; import { CnAsyncSelect, CnDemoBlock, CnDemoPage } from "../../.."; import { request } from 'cn-request'; export var 请求 = function () { return (React.createElement(CnDemoPage, { title: "\u8BF7\u6C42" }, React.createElement(CnDemoBlock, { title: "\u5E38\u89C4\u8FDC\u7A0B\u8BF7\u6C42", padding: 0 }, React.createElement(CnAsyncSelect, { remoteUrl: "https://rap2api.alibaba-inc.com/app/mock-scene/7053/api/select/cn-data-source?_tag=mock" })), React.createElement(CnDemoBlock, { title: "\u4F7F\u7528requestConfig\u914D\u7F6E\u8BF7\u6C42\u5730\u5740", padding: 0 }, React.createElement(CnAsyncSelect, { requestConfig: { url: 'https://rap2api.alibaba-inc.com/app/mock-scene/7053/api/select/cn-data-source?_tag=mock', } })), React.createElement(CnDemoBlock, { title: "\u81EA\u5B9A\u4E49\u8BF7\u6C42method", padding: 0 }, React.createElement(CnAsyncSelect, { remoteUrl: "https://rap2api.alibaba-inc.com/app/mock-scene/7053/api/select/cn-data-source?_tag=mock", requestConfig: { method: 'POST', } })), React.createElement(CnDemoBlock, { title: "\u8BF7\u6C42\u7ED3\u679C\u683C\u5F0F\u5316", padding: 0 }, React.createElement(CnAsyncSelect, { remoteUrl: "https://rap2api.alibaba-inc.com/app/mock-scene/7053/api/select/cn-data-source?_tag=mock", requestConfig: { formatResult: function (res) { return res.data.data.map(function (item) { return (__assign(__assign({}, item), { label: "[".concat(item.label, "]") })); }); }, } })), React.createElement(CnDemoBlock, { title: "\u4F7F\u7528\u81EA\u5B9A\u4E49\u7684service", padding: 0 }, React.createElement(CnAsyncSelect, { requestConfig: { service: function (key) { return request({ url: 'https://rap2api.alibaba-inc.com/app/mock-scene/7053/api/select/cn-data-source?_tag=mock', method: 'GET', params: { key: key, }, }); }, formatResult: function (res) { return res.data.data; }, } })), React.createElement(CnDemoBlock, { title: "\u8BF7\u6C42\u8F6E\u8BE2", padding: 0 }, React.createElement(CnAsyncSelect, { remoteUrl: "https://rap2api.alibaba-inc.com/app/mock-scene/7053/api/select/cn-data-source?_tag=mock", requestConfig: { pollingInterval: 1000, } })), React.createElement(CnDemoBlock, { title: "\u5C4F\u5E55\u805A\u7126\u65F6\u91CD\u65B0\u8BF7\u6C42", padding: 0 }, React.createElement(CnAsyncSelect, { remoteUrl: "https://rap2api.alibaba-inc.com/app/mock-scene/7053/api/select/cn-data-source?_tag=mock", requestConfig: { refreshOnWindowFocus: true, } })))); }; 请求.desc = '通过设置requestConfig配置不同请求'; export default { title: 'demo/CnAsyncSelect' };