[英]Modal windows in React
Here you can see my code in React.js在这里你可以看到我在 React.js 中的代码
I want to have several modal windows in one React component.我想在一个 React 组件中有几个模态 windows 。 I tried to use Modal from “react-native”, but it didn't work.
我尝试使用“react-native”中的 Modal,但没有成功。
Now I'm trying to use my own realisation of modal window, you can see it here.现在我正在尝试使用我自己实现的模态window,你可以在这里看到它。 I want to use this component for creating modal windows according to parameters.
我想使用这个组件根据参数创建模态 windows。
Unfortunately, this component creates modal windows with default values (null).不幸的是,该组件使用默认值(null)创建模态 windows。 I have watched lots of tutorials, but I still don't know how to fix it.
我看了很多教程,但我仍然不知道如何解决它。
I will be very grateful for help.我将非常感谢您的帮助。
I asume that you are passing some value to title
.我假设您正在将一些值传递给
title
。
You can add some ternary operators in the jsx
structure:您可以在
jsx
结构中添加一些三元运算符:
<div className="modalTitle">{title ? title : "what ever value you want"}</div>
Or you can add/set loader:或者您可以添加/设置加载程序:
return (
<>
{title ? (
<div>Your modal content here</div>
) : (
<div>Your loader here</div>
)}
</>
);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.