有來自lodash導入「模板」這樣的區別:從lodash和lodash/template中導入差異模板?
import { template } from 'lodash';
或者這樣:
import template from 'lodash/template';
第一替代工作正常,但是當我使用其他lodash功能的第二替代引發TypeError像模板中的_.isString一樣。
Uncaught TypeError: _.isString is not a function at eval (eval at (template.js:225), :10:13)
如果我調試的eval裏面,_(下劃線)對象看起來是這樣的:
Object {escape: function}
escape: function escape(string)
__proto__: Object
空除了一個逃生功能?
我想使用lodash/core和cherrypick這樣的非核心功能,比如「template」,但是這讓它很難。
環境:
- 的WebPack 1.13.0
- 通天6.24.1
- 骨幹1.3.3
- Lodash 4.17.4