2017-05-02 308 views
0

我綁加載MP3文件在我的Vue公司組成:(我使用Vue的-CLI樣板)MP3文件和Vue公司裝載機

const sound = new Audio(require("./sound.mp3"))) 

但我發現了這個錯誤:

Unexpected character ‘’ (1:3) You may need an appropriate loader to handle this file type.

這是一個很小的項目演示錯誤:https://github.com/life4ants/vue-audio-test

+0

你確定安裝了'file-loader'嗎? – thanksd

+0

@thanksd是的,它在我的package.json中 – Life4ants

回答

0

加入以下build/webpack.base.conf.js解決了這一問題:

{ 
    test: /\.mp3$/, 
    loader: 'url-loader', 
    options: { 
     limit: 10000, 
     name: utils.assetsPath('img/[name].[hash:7].[ext]') 
    } 
    }, 

該應用程序在上述鏈接已被更新,現在的作品。