UNPKG

antd-mobile-taro-ui

Version:

以antd-mobile为设计标准,基于taro框架的微信小程序组件库

21 lines (18 loc) 735 B
import Taro from '@tarojs/taro'; import { render, unmount as reactUnmount } from 'antd-mobile/es/utils/render'; export function renderToBody(element) { const container = document.createElement('view'); const currentPages = Taro.getCurrentPages(); const currentPage = currentPages[currentPages.length - 1]; const path = currentPage.$taroPath; const pageElement = document.getElementById(path); render(element, container); pageElement === null || pageElement === void 0 ? void 0 : pageElement.appendChild(container); function unmount() { const unmountResult = reactUnmount(container); if (unmountResult && container.parentNode) { container.parentNode.removeChild(container); } } return unmount; }