当前位置:网站首页>JS add spaces to the string

JS add spaces to the string

2022-07-07 11:09:00 Have a good time I

js String concatenation space , An old question about growth is often forgotten , Let's make a record
requirement : Because the specification configuration is string splicing , As shown in the figure, the specification configuration is required to add spaces to this character

I tried several methods, but they didn't work
1. direct +' ' Direct to ignore , No effect .
2. direct +'       ' Put... Directly       Output , Negative effects .
3. direct +'\xa0', Direct success , If you need a few spaces, just splice a few '\xa0'
The splicing method of the above figure is as follows :

 const specificationConfiguration =
        ' Resource name :' +
        conf.resourceName +'\xa0\xa0\xa0\xa0\xa0\xa0'+
        '  processor :' +
        conf.processor +'\xa0\xa0\xa0\xa0\xa0\xa0'+
        '  Memory :' +
        conf.memory +'\xa0\xa0\xa0\xa0\xa0\xa0'+
        '  computer network :' +
        conf.network +'\xa0\xa0\xa0\xa0\xa0\xa0'+
        '  Free :' +
        conf.freeCpus+' nucleus '
原网站

版权声明
本文为[Have a good time I]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202130619539177.html