ovidiupop / yii2-printthis
为 Yii Framework 2.0 通过选择器打印 html
dev-main
2024-01-15 16:37 UTC
Requires
- bower-asset/printthis: *
- yiisoft/yii2: 2.*
This package is auto-updated.
Last update: 2024-09-15 18:04:24 UTC
README
安装
composer require ovidiupop/yii2-printthis "@dev"
或者将此行添加到 composer.json 文件中
"ovidiupop/yii2-printthis": "@dev"
用法
要使用此小部件,请将以下代码插入到视图文件中
<?php echo PrintThis::widget([ 'htmlOptions' => [ 'id' => 'PrintThis', 'btnClass' => 'btn btn-info', 'btnId' => 'btnPrintThis', 'btnText' => 'Print', 'btnIcon' => 'fa fa-print' ], 'options' => [ 'debug' => false, 'importCSS' => true, 'importStyle' => false, 'loadCSS' => "path/to/my.css", 'pageTitle' => "", 'removeInline' => false, 'printDelay' => 333, 'header' => null, 'formValues' => true, ] ]); ?>
在打印区域的视图文件中
<div id="PrintThis"> Your Html code here </div>
你可以添加 CSS 来禁用链接显示
@media print { .noprint {display:none !important;} a:link:after, a:visited:after { display: none; content: ""; } }