supplyhog / yii2-clipboardjs
dev-master
2016-10-31 13:13 UTC
Requires
- php: >=5.4.0
- bower-asset/clipboard: ^1.5
- yiisoft/yii2: *
This package is not auto-updated.
Last update: 2024-09-23 07:26:39 UTC
README
在项目中使用 Clipboardjs 的简单方法。Clipboardjs 是一个仅使用 JavaScript 将文本复制到剪贴板的解决方案。
安装
通过 composer 安装此扩展。将以下行添加到您的项目 composer.json 文件中
"supplyhog/yii2-clipboardjs" : "dev-master"
用法
//Button to copy text <?= \supplyhog\ClipboardJs\ClipboardJsWidget::widget([ 'text' => "Hello World", // 'label' => 'Copy to clipboard', // 'htmlOptions' => ['class' => 'btn'], // 'tag' => 'button', ]) ?> //Button to copy text from input id <?= \supplyhog\ClipboardJs\ClipboardJsWidget::widget([ 'inputId' => "#input-url", // 'cut' => false, // Cut the text out of the input instead of copy? // 'label' => 'Copy to clipboard', // 'htmlOptions' => ['class' => 'btn'], // 'tag' => 'button', ]) ?>
仅资产?
是的,您可以使用仅资产。 php \supplyhog\ClipboardJs\ClipboardJsAsset::register($view)
它将自动初始化所有具有 "clipboard-js-init" 类的元素。