When I use Vue in an HTML file like below, it works fine.
<body>
<div id="app">
<!-- something in here -->
</div>
<script>
new Vue({
el: "#app",
data: function() {
}
//and so on ....
})
</script>
</body>
But When I use webpack to build it. The output js file which I put in HTML header does not parse the HTML correctly. And seems Vue.js is not working.
Here are my webpack config file and entry js file.
/**
* webpack.config.js
*/
const path = require('path');
module.exports = {
entry: './src/index.js',
output:{
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist')
},
module:{
rules:[
{
test: /\.css$/,
use:[
'style-loader',
'css-loader'
]
},
{
test: /\.(png|svg|jpg|gif|ico)$/,
use:[
'file-loader'
]
},
{
test: /\.(woff|woff2|eot|ttf|otf)$/,
use:[
'file-loader'
]
}
]
}
}
/**
* index.js (the entry js file)
*/
import axios from "axios";
import Vue from "vue";
var baseUrl = "/activity/gqzq/AjaxGetList";
var vm = new Vue({
el: "#app",
data: function() {},
//......
})
My question is, Why the output file is not working? And how to make it right?