<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"
}
}
网友评论