[英]range is not a function in lodash?
I have lodash cdn included in this fiddle https://jsfiddle.net/byhh6Lyo/ 我在这个小提琴中包含了lodash CDN https://jsfiddle.net/byhh6Lyo/
console.log(_)
console.log(_.range(1, 10))
_.map([1,2,3], (o) => console.log(o)) //worked
The second line has an error, saying range is not a function
, what's wrong? 第二行有错误,说
range is not a function
,怎么了?
The cdn you are using is not correct. 您使用的CDN不正确。 You were using
core
version which does not contain _.range
. 您使用的
core
版本不包含_.range
。 core
build has very limited features available. core
版本的可用功能非常有限。 Check here for more information : https://github.com/lodash/lodash/wiki/Build-Differences 在此处查看更多信息: https : //github.com/lodash/lodash/wiki/Build-Differences
Solution : Use the full version => https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.10/lodash.min.js 解决方案 :使用完整版本=> https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.10/lodash.min.js
Below is working fine: 以下工作正常:
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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.