2017-02-09 36 views
6

我與vue和vue-bulma選項卡有這個奇怪的錯誤。TypeError:嘗試使用vue-bulma-tabs時數據必須是字符串或緩衝區

Project is running at http://localhost:8081/ 
webpack output is served from /dist/ 
404s will fallback to /index.html 
crypto.js:74 
    this._handle.update(data, encoding); 
      ^

TypeError: Data must be a string or a buffer 
    at TypeError (native) 
    at Hash.update (crypto.js:74:16) 
    at HarmonyExportImportedSpecifierDependency.updateHash (/Users/esteban/Projects/experiments/example1/node_modules/webpack/lib/dependencies/HarmonyExportImportedSpecifierDependency.js:144:8) 
    at /Users/esteban/Projects/experiments/example1/node_modules/webpack/lib/DependenciesBlock.js:33:5 
    at Array.forEach (native) 
    at NormalModule.DependenciesBlock.updateHash (/Users/esteban/Projects/experiments/example1/node_modules/webpack/lib/DependenciesBlock.js:32:20) 
    at NormalModule.Module.updateHash (/Users/esteban/Projects/experiments/example1/node_modules/webpack/lib/Module.js:162:41) 
    at NormalModule.updateHash (/Users/esteban/Projects/experiments/example1/node_modules/webpack/lib/NormalModule.js:327:30) 
    at modules.forEach.m (/Users/esteban/Projects/experiments/example1/node_modules/webpack/lib/Chunk.js:253:31) 
    at Array.forEach (native) 

我認爲是有關webpack,但我沒有得到什麼問題或如何解決它。

重現它,只是這樣做

vue init webpack-simple example1 
cd example1 
npm i 
npm i -S bulma vue-bulma-tabs 

然後將其添加到main.js文件

import {Tabs, TabPane} from 'vue-bulma-tabs' 

然後運行

npm run dev 

等瞧!有錯誤。我錯過了什麼?

回答

1

我發現了這個問題,但我不確定是誰的錯。

vue-bulma-tabs使用不帶Vue文件擴展名的導入。但vue中的webpack-simple模板不支持該模板。

解決的辦法是配置的WebPack嘗試.vue以及在解決項下webpack.config.js .js文件 ,加

extensions: ['.js', '.vue']

,現在正在工作。

7

所以這個問題的根本原因是有一個導入,沒有找到您要導入的文件。有關解決方法,請參閱https://github.com/webpack/webpack/issues/4072#issuecomment-278626604以添加一些日誌記錄以幫助您查找無法導入的文件。

+0

確實找不到它,但問題是vue-bulma-tabs包使用不帶擴展名的vue文件加載,而使用vue cli創建的項目默認情況下不啓用該選項。主要問題是無法導入的文件不在我的項目代碼中,但是我正在加載一些軟件包。 – mcniac

+0

@carlous正是......這是根本原因 –

+0

這是非常有益的,謝謝卡洛斯! –

相關問題