Javascript Laravel 5.2-vue集成

Javascript Laravel 5.2-vue集成,javascript,laravel-5.2,vuejs2,Javascript,Laravel 5.2,Vuejs2,我有一个使用Laravel 5.2版本构建的遗留项目,我想知道如何使用它设置Vue。我已将vue添加到package.json文件中: { "private": true, "scripts": { "prod": "gulp --production", "dev": "gulp watch" }, "devDependencies": { "gulp": "^3.9.1", "laravel-elixir": "^5.0.0", "bo

我有一个使用Laravel 5.2版本构建的遗留项目,我想知道如何使用它设置Vue。我已将vue添加到package.json文件中:

{
  "private": true,
  "scripts": {
    "prod": "gulp --production",
    "dev": "gulp watch"
  },
  "devDependencies": {
    "gulp": "^3.9.1",
    "laravel-elixir": "^5.0.0",
    "bootstrap-sass": "^3.0.0",
    "vue": "^2.0.1"
  }
}
我已经在resources/assets/js文件夹中创建了
bootstrap.js
app.js
文件:

bootstrap.js

window._ = require('lodash');

/**
 * Vue is a modern JavaScript library for building interactive web interfaces
 * using reactive data binding and reusable components. Vue's API is clean
 * and simple, leaving you to focus on building your next great project.
 */

window.Vue = require('vue');
require('./bootstrap');

/**
 * First we will load all of this project's JavaScript dependencies which
 * include Vue and Vue Resource. This gives a great starting point for
 * building robust, powerful web applications using Vue and Laravel.
 */

/**
 * Next, we will create a fresh Vue application instance and attach it to
 * the body of the page. From here, you may begin adding components to
 * the application, or feel free to tweak this setup for your needs.
 */

Vue.component('image-input', require('./components/ImageInput.vue'));

const app = new Vue({
    el: '#app'
});
app.js

window._ = require('lodash');

/**
 * Vue is a modern JavaScript library for building interactive web interfaces
 * using reactive data binding and reusable components. Vue's API is clean
 * and simple, leaving you to focus on building your next great project.
 */

window.Vue = require('vue');
require('./bootstrap');

/**
 * First we will load all of this project's JavaScript dependencies which
 * include Vue and Vue Resource. This gives a great starting point for
 * building robust, powerful web applications using Vue and Laravel.
 */

/**
 * Next, we will create a fresh Vue application instance and attach it to
 * the body of the page. From here, you may begin adding components to
 * the application, or feel free to tweak this setup for your needs.
 */

Vue.component('image-input', require('./components/ImageInput.vue'));

const app = new Vue({
    el: '#app'
});
这是组件
ImageInput.vue

<template>
    <div>
        <div class="row">
            <div class="large-6 columns">
                <div class="Image-input__image-wrapper">
                    <i v-show="! imageSrc" class="icon fa fa-picture-o"></i>
                    <img v-show="imageSrc" class="Image-input__image" :src="imageSrc">
                    <i v-show="imageSrc" @click="removeImage" class="remove fa fa-times"></i>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="large-6 columns">
                <div class="Image-input__input-wrapper">
                    Last opp bilder
                    <input @change="previewThumbnail" class="Image-input__input" name="image" type="file">
                </div>
            </div>
        </div>
    </div>
</template>
<script>
export default {

  props: ['imageSrc'],

  methods: {
    previewThumbnail: function(event) {
      var input = event.target;

      if (input.files && input.files[0]) {
        var reader = new FileReader();

        var vm = this;

        reader.onload = function(e) {
          vm.imageSrc = e.target.result;
        }

        reader.readAsDataURL(input.files[0]);
      }
    },
    removeImage: function removeImage(e) {
      this.imageSrc = '';
      document.querySelectorAll('input[type=file]').forEach(element => {
          element.value = "";
      });
      document.getElementById('oldImage').value = '';
    }
  }
}
</script>
但是,在终端中运行gulp命令后,我得到一个错误:

吞咽通知:[Laravel Elixir]浏览失败!:意外标记

/home/vagrant/Projects/flight park backend/resources/assets/js/components/ImageInput.vue:1

用于:


你试过拉维长生不老药吗?
你试过拉维长生不老药吗?

您可以简单地从CDNYeah添加一个脚本链接,但这不是我想要的。您可以简单地从CDNYeah添加一个脚本链接,但这不是我想要的。谢谢,在安装它之后,我只需将bootstrap.js中的vue文件的导入更改为:
window.vue=require('vue/dist/vue.common')谢谢,就是这样,安装之后,我只需将bootstrap.js中vue文件的导入更改为:
window.vue=require('vue/dist/vue.common')