我是Lodash的初学者,我想把字符串'anotherpost‘转换成字符串’另一个帖子‘。另一个和post之间没有差距。但当我用
let title = _.lowerCase('AnotherPost');
console.log(title);<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.21/lodash.min.js" integrity="sha512-WFN04846sdKMIP5LKNphMaWzU7YpMyCU245etK3g/2ARYbPK9Ub18eG+ljU96qKRCWh+quCY7yefSmlkQw1ANQ==" crossorigin="anonymous"></script>
它用我不想要的空格记录字符串“另一个帖子”。有人能帮我吗?
发布于 2021-03-08 08:45:58
_.lowerCase()方法将字符串转换为小写,单词之间有空格。
用于Lodash的_.toLower()或JS String.toLowerCase()
console.log(_.lowerCase('AnotherPost')); // another post
console.log(_.toLower('AnotherPost')); // anotherpost
console.log('AnotherPost'.toLowerCase()); // anotherpost<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.21/lodash.min.js" integrity="sha512-WFN04846sdKMIP5LKNphMaWzU7YpMyCU245etK3g/2ARYbPK9Ub18eG+ljU96qKRCWh+quCY7yefSmlkQw1ANQ==" crossorigin="anonymous"></script>
https://stackoverflow.com/questions/66526569
复制相似问题