Skip to content

bestyii/yii2-clipboardjs

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 

Repository files navigation

yii2-clipboardjs 复制到剪贴板

基于Clipboardjs 实现一键复制内容到剪贴板.

Clipboardjs 是纯JavaScript实现的.

安装 Installation

通过 composer安装扩展. 添加下面代码到项目的 composer.json文件中

"bestyii/yii2-clipboardjs":"*",

使用 Usage

//渲染带输入框的控件
<?= \bestyii\clipboardjs\ClipboardInputWidget::widget([
            'text' => 'https://www.bestyii.com',
             'label' => '复制到剪贴板',
             'successText' => '复制成功!',
        ]) ?>

//按钮形式
<?= \bestyii\clipboardjs\ClipboardJsWidget::widget([
    'text' => "Hello World",
    // 'label' => 'Copy to clipboard',
    // 'htmlOptions' => ['class' => 'btn'],
    // 'tag' => 'button',
]) ?>

//点击按钮复制指定id的input值
<?= \bestyii\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',
]) ?>

直接调用静态资源 Just the Asset?

Yes, you can use just the asset.

 \bestyii\clipboardjs\ClipboardJsAsset::register($view);

It will auto init anything with the "clipboard-js-init" class.

About

Yii2 extension for easy use of Clipboard.js

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%