reactjs - 我想打印模型盒
问题描述
我想打印页面的模型框,但没有打印按钮本身。我已经尝试过这段代码,但它没有用。我是新来的反应。帮助。
代码如下:
import React from "react";
import "./Bill.css";
import logo from "./images/logo.png";
import { Link, useHistory } from "react-router-dom";
import ClientDashboard from "./ClientDashboard";
import BillTable from "./BillTable";
function Bill() {
const history = useHistory();
const logout = (e) => {
localStorage.removeItem("token");
history.push("/");
};
if (!localStorage.getItem("token")) {
history.push("/");
}
return (
<div className="modal__bill">
<div className="bill__navbar">
<Link to="/clientdashboard" className="header__link">
<img className="navbar__logo" src={logo} alt="logo" />
</Link>
</div>
<div className="box">
<BillTable />
<button className="print__button" onClick={() => window.print()}>
Print
</button>
</div>
</div>
);
}
export default Bill;
解决方案
你试过用css隐藏按钮吗?
在您的情况下,您可以添加
@media print {
.print__button {
display: none !important;
}
}
推荐阅读
- php - Zend Framework 3 中的公用文件夹
- servlets - Glassfish 5:指定文档库以将上传的文件存储在服务器的文件系统上
- javascript - 提交没有表单 ID 的表单
- excel - 将值从 ListBox 复制到工作表单元格
- php - 如何获取会话和比较
- vue.js - Laravel Mix Vue,使用Vue Router时延迟加载组件返回错误作为未知自定义元素
- c++ - 在 NativeActivity 中处理输入
- android - GridLayout 中的 ImageView
- excel - 如何在公式中查找其他表格的内容?
- sql - 查询以获取特定客户的数据计数以及表中的所有其他数据