可以直接引入
import { cloneDeep } from "lodash";
import * as _ from "lodash";
还有一种方式用的比较少...把import当成const使用, 不知道有什么作用... 反正都是引进来就能用
import debounce = require("lodash/debounce");
import cloneDeep = require("lodash/cloneDeep");
引入自己的脚本也是一样的
import { fib } from "./utils";
鼠标移动事件的节流处理
const debounceTime = 100;
const move = throttle((e) => {
const location = e.getLocation();
this.center.x = location.x - this.w / 2;
this.center.y = location.y - this.h / 2;
}, debounceTime);
cc.director
.getScene()
.getChildByName("Canvas")
.on(cc.Node.EventType.MOUSE_MOVE, move);
来源:oschina
链接:https://my.oschina.net/ahaoboy/blog/4776076