javascript - Ionic 5 Modal 仅显示按钮而没有其他内容 - React
问题描述
所以我一直在尝试IonModal
使用 React 在 Ionic 5 上使用。但是,当在模态框内显示元素时,只会显示按钮。有没有人遇到过这个?澄清一下,当模式打开时,只显示提交和取消按钮,但我希望IonInput
和也div
出现h1
。
进口:
import React from "react";
import { connect } from "react-redux";
import { Redirect } from "react-router";
import { checkAuthenticated, load_user } from "./actions/auth";
import { MapContainer, TileLayer, Marker, Popup } from "react-leaflet";
import "./App.css";
import campimg from "./assets/img/campimg.jpeg";
import backpack from "./assets/img/backpack.png";
import { useCurrentLocation, geolocationOptions } from "./actions/spots";
import {
IonButton,
IonContent,
IonInput,
IonModal,
IonPage,
} from "@ionic/react";
const [showModal, setShowModal] = React.useState(false);
<IonPage>
<IonContent>
<IonModal isOpen={showModal}>
<div>
<h1>Hello User! You can enter data here:</h1>
</div>
<IonInput placeholder="Title"></IonInput>
<IonButton shape="round" class="button_primary_white_text">
Submit
</IonButton>
<IonButton
shape="round"
class="button_secondary_white_text"
onClick={() => setShowModal(false)}
>
Cancel
</IonButton>
</IonModal>
<h1>Hello {name["first_name"]}!</h1>
<IonButton
shape="round"
class="button_secondary_white_text"
onClick={() => setShowModal(true)}
>
Add Spot
</IonButton>
</IonContent>
</IonPage>
解决方案
推荐阅读
- python - Flask 会话值不会保存在不同的请求中
- php - 如果相同日期,则 CSV 覆盖行,否则附加到新行
- python - 使用 Scapy 构建的网络扫描仪仅扫描自身
- python - 计算某个位置在列表中显示的次数
- reactjs - 如何为表单数据设置状态变量
- c++ - 在派生类中访问基类属性或字段的方法是什么?
- node.js - 异步和等待函数 Node.js
- html - 在引导程序中更改网格的背景颜色,包括它没有到达的边
- swift - 如何在 SwiftUI 中包含和调用 BSImagePicker
- r-markdown - Bookdown / Knitr / Kable 完美输出到 HTML 但没有表格到 PDF