Vue加载audio文件错误的解决
2018-06-12 本文已影响0人
张先森Mr_zhang
<audio id="voice" src="~@/assets/Anniversary/h5-bg.mp3" autoplay="autoplay"></audio>
在webpack.base.config.js加上
{
test: /\.mp3(\?.*)?$/,
loader: 'url-loader',
options: {
limit: 10000,
name: utils.assetsPath('media/[name].[hash:7].[ext]')
}
}
将vue-loader.conf.js改为
var utils = require('./utils')
var config = require('../config')
var isProduction = process.env.NODE_ENV === 'production'
module.exports = {
loaders: utils.cssLoaders({
sourceMap: isProduction
? config.build.productionSourceMap
: config.dev.cssSourceMap,
extract: isProduction
}),
transformToRequire: {
"audio": "src"
}
}