tarojs-popups
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

tarojs-popups

安装

$ npm install tarojs-popups
# or
$ yarn add tarojs-popups

使用

import { Button, View } from '@tarojs/components'
import Taro from '@tarojs/taro'
import React, { FC } from 'react'
import 'tarojs-popups/dist/index.css'
import { Popups, useController } from 'tarojs-popups'  // 引入

const Test: FC<{name?:string}> = (props) => {
  const ctx = useController()
  return (
      <View style={{background:'#fff'}}>
          <View>你好,{props.name}</View>
          <Button onClick={() => ctx.close('我是数据')}>关闭弹窗并返回数据<Button>
      </View>
  )
}

export default function IndexPage {
  return (
    <View className="index">
      <Popups />
      <Button
        onClick={async () => {
          const value = await Popups.open({
            el: Test,
            props: { name: 'tarojs-popups' },
            position: 'bottom',
          })
          console.log('获得数据',value)
        }}
      >
        弹出窗口
      </Button>
    </View>
  )
}

Readme

Keywords

none

Package Sidebar

Install

npm i tarojs-popups

Weekly Downloads

3

Version

0.0.2

License

MIT

Unpacked Size

71.3 kB

Total Files

17

Last publish

Collaborators

  • libeilong