【问题标题】:Vue and webpack warningVue 和 webpack 警告
【发布时间】:2017-09-09 13:28:04
【问题描述】:

我想将 Vue 与 webpack 一起使用。我已经安装了所有依赖项,但编译后我有警告:

[Vue 警告]:您正在使用 Vue 的仅运行时构建,其中 模板编译器不可用。预编译模板 进入渲染函数,或使用编译器包含的构建。 (在发现 )

我的 app.js:

import Vue from 'vue';
import test from './components/cartItem.vue'; // Simple <template> with string

new Vue({
  el: '#js-cart-list'
});

我的 package.json :

  "devDependencies": {
    "autoprefixer": "^6.4.1",
    "babel-core": "^6.14.0",
    "babel-loader": "^6.2.5",
    "babel-polyfill": "^6.23.0",
    "babel-preset-es2015": "^6.14.0",
    "babel-preset-stage-2": "^6.13.0",
    "browser-sync": "^2.14.3",
    "cross-env": "^3.2.4",
    "css-loader": "^0.24.0",
    "css-mqpacker": "^5.0.1",
    "eslint": "^3.18.0",
    "eslint-loader": "^1.6.3",
    "exports-loader": "^0.6.3",
    "extract-text-webpack-plugin": "^2.1.0",
    "goog-webfont-dl": "^1.0.1",
    "node-sass": "^3.8.0",
    "postcss-loader": "^0.11.1",
    "progress-bar-webpack-plugin": "^1.9.0",
    "sass-loader": "^4.0.1",
    "script-loader": "^0.7.0",
    "slick-carousel": "^1.6.0",
    "style-loader": "^0.13.1",
    "vue-loader": "^11.3.4",
    "vue-template-compiler": "^2.2.6",
    "webpack": "^2.0.0",
    "webpack-notifier": "^1.5.0"
  },
  "dependencies": {
    "family.scss": "^1.0.8",
    "foundation-sites": "^6.3.0",
    "jquery": "^2.2.0",
    "motion-ui": "^1.1.1",
    "select2": "^4.0.3",
    "vue": "^2.2.6"
  }

这是我第一次使用 vue 和 webpack,有人知道吗?

谢谢!

【问题讨论】:

  • 请编辑您的问题以包含您的webpack.config.js - 这几乎肯定是问题所在。

标签: webpack vue.js


【解决方案1】:

你应该把它添加到你的 webpack 配置文件中:

resolve: {
  alias: {
    vue: 'vue/dist/vue.js'
  }
}

预编译的组件,你也应该把它们全部放在 *.vue 文件中。

看看这个:https://github.com/vuejs-templates/webpack/issues/215

【讨论】:

  • 看起来我们也可以将“main.js”文件重命名为.vue
猜你喜欢
  • 2019-10-14
  • 2017-06-01
  • 2018-06-07
  • 1970-01-01
  • 2019-02-12
  • 2021-06-20
  • 2019-04-11
  • 2019-02-10
  • 1970-01-01
相关资源
最近更新 更多