reactjs 如何改变脉轮ui吐司组件的位置

tf7tbtn2  于 9个月前  发布在  React
关注(0)|答案(1)|浏览(90)

我想把吐司不仅换到底部,还要换到另一个盒子的底部。
我尝试了门户,但我吐司门户不去下框组件
这就是我所尝试的

import { Button, CloseButton, Flex, Image, Portal, useDisclosure, useToast } from "@chakra-ui/react";

const toast = useToast();
const toastTest = ()=>{
const toastRef = useRef<HTMLButtonElement>(null);
return(
<Portal containerRef={toastRef}>
    <Flex width={"300px"} height={"300px"}>
        <Button
            onClick={() => {
                toast();
            }}
        >
            Show Toast2
        </Button>
    </Flex>
</Portal>
<Flex width={"100%"} height={"1300px"} backgroundColor={"green.100"}>
        asdfsdzf
<Flex width={"100px"} height={"100px"} backgroundColor={"red.100"} ref={toastRef}></Flex>
</Flex>)}

字符串

xuo3flqw

xuo3flqw1#

在脉轮用户界面中,你可以找到改变烤面包位置的代码:
https://chakra-ui.com/docs/components/toast/usage#changing-the-toast-position
基本上,你只需要使用toast方法和props,就像这样:

toast({
   position: 'top',
   title: 'Test Toast!',
   description: 'This is a test toast'
  })

字符串

相关问题