2017-10-16 56 views
1

在我的webpack配置中使用預渲染插件時,我一直在運行命令npm run build時遇到問題。Vue.js pre-rendering使用prerender-spa-plugin在執行時凍結-npm run build

我用的是的WebPack高級選項:

`captureAfterDocumentEvent: 'fetch-done',` 

而在代碼中,我使用的是承諾包API調用,然後分派一個新的事件。

`new Promise(resolve => { 
     axios.get(url) 
      .then((res) => { 
      console.log(res.data); 
      this.message = res.data.short_name; 
      resolve(); 
      }); 
     }).then(() => { 
     document.dispatchEvent(new Event('fetch-done')); 
     });` 

通過這樣做,運行npm run build命令不會引發任何錯誤,但它永遠不會完成。

你有任何建議使這項工作?

回答

0

captureAfterDocumentEvent: 'fetch-done'不能正常工作......

你可以嘗試用的setTimeout來包裝你dispatchEvent喜歡它建議here