需求,给计数器添加单位%
html内容
<el-input-number v-model="requiredProgress" label="描述文字" id="rebateInput" size="mini" @change="addCompany" ></el-input-number>
js内容
mounted() { this.addCompany(); }, methods: { changeProgress() { this.addCompany(); }, addCompany() { const span = document.createElement('span'); const innerspan = document.createElement('span'); const textspan = document.createElement('span'); span.setAttribute('class', 'el-input__suffix'); span.setAttribute('style', 'right:36px'); innerspan.setAttribute('class', 'el-input__suffix-inner'); span.append(innerspan); innerspan.append(textspan); textspan.append('%'); this.$nextTick(() => { document.getElementById('rebateInput').lastElementChild.prepend(span); }); }, },
本文作者为gengboxb,转载请注明。