Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用webpack运行vue_Webpack_Vue.js - Fatal编程技术网

使用webpack运行vue

使用webpack运行vue,webpack,vue.js,Webpack,Vue.js,我正在尝试使用webpack运行vue,但当我运行webpack时,index.html显示一个空白页。我的代码有什么问题 index.html <html lang="en"> <head> <meta charset="utf-8"> <title>Vue Example</title> </head> <body> <div id="app">{{ messa

我正在尝试使用webpack运行vue,但当我运行
webpack
时,
index.html
显示一个空白页。我的代码有什么问题

index.html

<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>Vue Example</title>
  </head>
  <body>
    <div id="app">{{ message }}</div>
    <script src="dist/build.js"></script>
  </body>
</html>


使用VUE时,网页包本身的配置非常用户友好,但对于初学者来说,很容易出错。导致项目出错,就像你没有走出页面一样

在使用vue的项目中,个人不建议单独配置webpack和vue loader。您可以直接使用vue官方脚手架,即vue cli。不必考虑这些配置,自动配置。

如果您刚刚开始学习Vue,这里有一个入门级演示。虽然它只是一个小应用,但它涵盖了很多知识点(vue2.0+vue cli+vue router+vuex+axios+mysql+express+pm2+webpack),包括前端、后端、数据库等网站的一些必要元素,对我来说,学习意义重大,希望相互鼓励


使用VUE时,网页包本身的配置非常用户友好,但对于初学者来说,很容易出错。导致项目出错,就像你没有走出页面一样

在使用vue的项目中,个人不建议单独配置webpack和vue loader。您可以直接使用vue官方脚手架,即vue cli。不必考虑这些配置,自动配置。

如果您刚刚开始学习Vue,这里有一个入门级演示。虽然它只是一个小应用,但它涵盖了很多知识点(vue2.0+vue cli+vue router+vuex+axios+mysql+express+pm2+webpack),包括前端、后端、数据库等网站的一些必要元素,对我来说,学习意义重大,希望相互鼓励


您的控制台是否显示错误?我将把这个留在这里,以便您可以查看我的功能版本的网页配置:我看不到您的脚本或html有任何问题,因此问题可能在您的网页中。下面是我如何运行我的webpack命令(需要您从npm安装cross-env):cross env NODE_env=开发网页包--进度--隐藏模块您的控制台是否显示错误?我将把这个留在这里,以便您可以查看我的功能版本的网页包配置的外观:我看不到您的脚本或html有任何问题,因此问题可能出在您的网页包中。下面是我如何运行我的webpack命令(需要您从npm安装cross env):cross env NODE_env=开发webpack--进度--隐藏模块
//main.js
import Vue from 'vue'

var a = new Vue({
  el: '#app',
  data: {
    message: "i know you"
  }
})
//webpack.config.js
module.exports = {
    // This is the "main" file which should include all other modules
    entry: './src/main.js',
    // Where should the compiled file go?
    output: {
        // To the `dist` folder
        path: './dist',
        // With the filename `build.js` so it's dist/build.js
        filename: 'build.js'
    },
    module: {
        // Special compilation rules

        loaders: [
            {
                // Ask webpack to check: If this file ends with .js, then apply some transforms
                test: /\.js$/,
                // Transform it with babel
                loader: 'babel',
                // don't transform node_modules folder (which don't need to be compiled)
                exclude: /node_modules/

            }
        ]
    }
}