我有lodash cdn包含在这个小提琴https://jsfiddle.net/byhh6Lyo/
中console.log(_)
console.log(_.range(1, 10))
_.map([1,2,3], (o) => console.log(o)) //worked
第二行有错误,说range is not a function
,出了什么问题?
答案 0 :(得分:4)
您使用的cdn不正确。您使用的core
版本不包含_.range
。 core
版本的功能非常有限。点击此处查看更多信息:https://github.com/lodash/lodash/wiki/Build-Differences
解决方案:使用完整版本=> https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.10/lodash.min.js
以下工作正常:
console.log(_)
console.log(_.range(1, 10))
_.map([1, 2, 3], (o) => console.log(o)) //worked

<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.10/lodash.min.js"></script>
&#13;