el-input 后面加
如果想要在 <el-input> 后面加上百分号(%),可以使用以下方法:
- 使用插槽(slot):可以在
<el-input>标签中使用插槽来添加百分号。首先,在<el-input>标签内部添加一个<template>标签,并设置插槽名为 suffix(后缀)。然后,在<template>标签内部添加一个<span>标签,并设置内容为百分号(%)。 示例代码如下:
<el-input>
<template slot="suffix">
<span>%</span>
</template>
</el-input>
- 使用 CSS 样式:可以使用 CSS 样式来为
<el-input>添加一个伪元素,然后设置伪元素的内容为百分号(%)。首先,为<el-input>添加一个类名(例如:input-with-percent)。然后,在 CSS 文件中使用该类名来添加伪元素,并设置内容为百分号(%)。 示例代码如下: HTML:
<el-input class="input-with-percent"></el-input>
CSS:
.input-with-percent::after {
content: "%";
}
以上两种方法都可以实现在 <el-input> 后面添加百分号(%),选择其中一种方法即可
原文地址: https://www.cveoy.top/t/topic/iPI6 著作权归作者所有。请勿转载和采集!