Vuex: local example cart show Vue warn

Created on 20 Jul 2016  ·  3Comments  ·  Source: vuejs/vuex

I want to run cart locally.

When I use the file in the folder examples,It is OK

But,when I write the example in my own folder,It show Vue warn

vue.common.js:2231[Vue warn]: You are using the runtime-only build of Vue where the template option is not available. Either pre-compile the templates into render functions, or use the compiler-included build. (found in component )

the package.json is:

"devDependencies": {
    "babel-core": "^6.2.1",
    "babel-loader": "^6.2.0",
    "babel-plugin-transform-runtime": "^6.1.18",
    "babel-polyfill": "^6.2.0",
    "babel-preset-es2015": "^6.1.18",
    "babel-preset-es2015-rollup": "^1.1.1",
    "babel-preset-stage-2": "^6.1.18",
    "babel-runtime": "^6.0.0",
    "css-loader": "^0.23.1",
    "style-loader": "~0.12.3",
    "vue": "^2.0.0-alpha.7",
    "vue-hot-reload-api": "^1.3.2",
    "vue-html-loader": "^1.2.1",
    "vue-loader": "^8.2.2",
    "vue-style-loader": "^1.0.0",
    "vuex": "^1.0.0-rc.2",
    "webpack": "^1.13.1",
    "webpack-dev-server": "^1.14.1",
    "webpack-notifier": "^1.3.0"
  }
"scripts": {
    "cart": "webpack-dev-server --inline --hot"
  },

the webpack.config.js is:

module.exports = {
  entry: './main.js',
  output: {
    path: __dirname,
    filename: 'build.js'
  },
  module: {
    loaders: [
      {
        test: /\.js$/,
        loader: 'babel',
        exclude: /node_modules|vue\/dist|vue-hot-reload-api|vue-loader/
      },
      {
        test: /\.vue$/,
        loader: 'vue'
      }
    ]
  },
  devtool: '#source-map'
}

the .babelrc is:

{
  "presets": ["es2015", "stage-2"]
}

App.vue is:

<template>
  <div class="app">
    <h1>购物车示例</h1>
    <hr>
    <h2>产品</h2>
    <product-list></product-list>
    <hr>
    <cart></cart>
  </div>
</template>
<script>
  import ProductList from './ProductList.vue'
  import Cart from './Cart.vue'

  export default {
    name: 'App',
    components: { ProductList, Cart }
  }

</script>

I'm very grateful if someone can help me find out the cause

Most helpful comment

You ca fix this by using the standalone build of vue

import Vue from 'vue/dist/vue.js';

The issue I'm having is in the Chat app with the store; I keep getting

vuex.js?4979:509 Uncaught TypeError: Cannot set property threads of #<Object> which has only a getter

All 3 comments

You ca fix this by using the standalone build of vue

import Vue from 'vue/dist/vue.js';

The issue I'm having is in the Chat app with the store; I keep getting

vuex.js?4979:509 Uncaught TypeError: Cannot set property threads of #<Object> which has only a getter

It looks like the version of vue-loader is old. You should use vue-loader >=9.0.0 to use vue 2.0.
Please try npm install -D vue-loader@next

solving the problem with vue-loader >= 9.0.0

Was this page helpful?
0 / 5 - 0 ratings