You’re exporting an object, defined using ES2015 shorthand object literal syntax, as the default export. Here is the long form equivalent of what you’ve written:
export default {
range: range,
select: select,
selectAll: selectAll,
event: event,
transition: transition
}
Your object thus captures the value of event
on load, which is null; it is not a live binding, and won’t reflect the current event.
One fix would be to define the event
property using a getter:
export default {
range,
select,
selectAll,
get event() { return event; },
transition
}
Better would be to use named exports instead of a default export, and then Rollup will generate a live binding automatically:
export {
range,
select,
selectAll,
event,
transition
}
This is not only shorter, but now you don’t depend on the browser supporting the ES2015 shorthand object literal syntax.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…