簡體   English   中英

React NPM 包(Dragula)可用於開發但不能用於生產

[英]React NPM package(Dragula) works in development but not in production

我已經用 React 15 和 Dragula 3.7.2 構建了一個不錯的拖放,但是當我捆綁我的生產應用程序時,整個 dnd 事情不起作用,除非我能夠提起單個元素但找不到將其放入的容器。

我正在為我的容器分配對我當前在 componentDidMount 中創建的 drake 實例的引用。

我已將多個 EventListener 分配給 drake 實例,但唯一觸發的是“drag”-eventListener。 我在那里 console.logged drake 實例並看到我所有相關的容器都正確分配

我還認為 dragula 包可能會出現縮小失敗,所以我使用了 cdn 中的版本

 class ProcessGridDrag extends React.Component { constructor() { super(); this.dragContext = null; this.dragContainers = []; } componentDidMount() { // eslint-disable-next-line no-undef this.drake = dragula(this.dragContainers, options); console.log('didMount'); console.log(this.drake.containers); this.drake.on('drop', this.onDropTile); this.drake.on('out', this.onOutContainer); this.drake.on('over', console.log); this.drake.on('drag', () => { debugger; console.log(this.drake); }); this.drake.on('shadow', console.log); // Override for touchmove for correct behaviour on iPad window.addEventListener('touchmove', () => {}); } componentWillUnmount() { this.dragContainers = []; console.log('will Unmount'); this.drake.containers = []; this.drake.off('drop', this.onDropTile); this.drake.off('out', this.onOutContainer); this.dragContext = null; this.drake.destroy(); } // This one is passed down to components which should act as a drag container dragulaDecorator = componentBackingInstance => { if ( componentBackingInstance && this.dragContainers.indexOf(componentBackingInstance) === -1 ) { this.dragContainers.push(componentBackingInstance); } };

webpack.config.prod: https://pastebin.com/BLu2hmmv webpack.config.dev: https://pastebin.com/3wczNisj

我的 css 有問題。 我已經覆蓋了拖動元素的最高值。

由於生產中的 LoadOrder 不同,這個問題只發生在那里

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM