<meta charset="utf-8"/>
<script src="../underscore.js"></script>
<script src="../underscore.string.js"></script>
<script src="../jquery.js"></script>
<script src="../backbone.js"></script>
<script>
//TypeError: _(...).chain(...).trim is not a function
console.log(_(" epeli ").chain().trim().capitalize().value());
</script>
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
是因为
_.string
这个扩展没有融入到_
对象里面去,所以你新建的_
对象没有包括string
扩展的函数导致的,再运行之前加上这句把扩展导入进去就好了。最好看下源码,现在最新的underscore.string 3.1.1暴露出来的对象是s。感觉underscore.string要独立于underscore似的