achieve effect
As shown in the picture, I want to realize that the QR code pictures can be disabled
switched according to different states. Originally, I used two img
to implement it, but img
I also need to set the pictures to be non-clickable. Although it can be achieved css
by using it cursor:no-drop
, it suddenly occurred to me that button
it will be supported by default disabled
. I Just set the image of this QR code as button
a custom icon, and I can use it button
to disabled
control whether it can be clicked.
Code
button
Customize icon
an icon name with the attribute. This custom icon name will be added to the button
lower i
label by default class
. We only need to set i
the style of the label.
<el-button
slot="reference"
type="text"
icon="el-icon-my-qr-code"
:class=" //控制显示图标的颜色
hasIncludeHttpText(row)
? 'qr-code-icon-default'
: 'qr-code-icon-disabled'
"
:disabled="!hasIncludeHttpText(row)"
></el-button>
You need to pay attention when setting styles /deep/
. Because these styles are not in the current component, /deep/
it is useless if you don’t set them. Of course, if you do n’t add them, scoped
you don’t need to add /deep/
them .
.qr-code-icon-default {
/deep/ .el-icon-my-qr-code {
background: url('~@home/assets/images/qr-code-icon.svg') no-repeat;
}
}
.qr-code-icon-disabled {
/deep/ .el-icon-my-qr-code {
background: url('~@home/assets/images/disabled-qr-code-icon.svg') no-repeat;
}
}
/deep/.el-icon-my-qr-code {
font-size: 16px;
background-size: cover;
}
/deep/ .el-icon-my-qr-code:before {
content: '替';
font-size: 16px;
visibility: hidden;
}