这是我的html
<div class="pr-2" style="width: 130px">
<div *ngIf="!element.editing" >
<span class="ss">{{element.barcode}}</span>
</div>
<div *ngIf="element.editing" >
<input type="text" [(ngModel)]="element.barcode" style="width: 130px"/>
</div>
</div>
这是我的CSS
.ss {
font-family: 'Libre Barcode 128 Text', cursive;
font-size: 22px;
}
这是我的javascript函数
barcodeGenerator(value){
let x = value
let i, j, intWeight, intLength, intWtProd = 0, arrayData = [];
let arraySubst = [ "Ã", "Ä", "Å", "Æ", "Ç", "È", "É", "Ê" ];
/*
* Checksum Calculation for Code 128 B
*/
intLength = x.length;
arrayData[0] = 104; // Assume Code 128B, Will revise to support A, C and switching.
intWtProd = 104;
for (j = 0; j < intLength; j += 1) {
arrayData[j + 1] = x.charCodeAt(j) - 32; // Have to convert to Code 128 encoding
intWeight = j + 1; // to generate the checksum
intWtProd += intWeight * arrayData[j + 1]; // Just a weighted sum
}
arrayData[j + 1] = intWtProd % 103; // Modulo 103 on weighted sum
arrayData[j + 2] = 106; // Code 128 Stop character
const chr = parseInt(arrayData[j + 1], 10); // Gotta convert from character to a number
if (chr > 94) {
var chrString = arraySubst[chr - 95];
} else {
chrString = String.fromCharCode(chr + 32);
}
// document.getElementById(id).innerHTML =
return 'Ì' + // Start Code B
x + // The originally typed string
chrString + // The generated checksum
'Î'; // Stop Code
// return `<span class="ss">${x}</span>`;
}
这是输出enter image description here
但我想隐藏/删除条形码下的文本。
就像这个enter image description here
2条答案
按热度按时间pgvzfuti1#
您应使用其他条形码字体,不带文本。
首先包含正确的webfont:
然后将css:
rdrgkggo2#
作为替代方案
将html更改为以下内容(额外范围):
而CSS对此:
}
这将隐藏条形码下的字母。