这个问题与
使用 webpack 运行 vue 有关
我会很感激回答为什么我不能简单地通过创建来初始化 Vue 和 Webpack 应用程序:
index.js
import Vue from 'vue';
let app = new Vue({
el: '#app',
data: {
message: 'message'
}
});
索引.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Vue Playground</title>
</head>
<body>
<div id="app">
{{ message }}
</div>
</body>
</html>
这是我的 webpack 配置文件:
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
entry: './src/index.js',
output: {
filename: 'main.js',
path: path.join(__dirname, 'dist')
},
plugins: [new HtmlWebpackPlugin({
template: './src/index.html'
})]
};
通过这种方式,根(#app)被Vue简单地从HTML文件中删除。我是 Vue 的新手,很高兴得到解释。我有一种学习方式,在学习复杂的解决方案之前,@vue/cli我希望分析它的依赖关系。
我应该只和 一起工作vue-loader吗?据我所知,它是用来解析 .vue 文件的,但我这里不需要。
先感谢您。