[Vuejs]-How to use vuejs with symfony

3👍

Install Webpack-Encore-Bundle and inside of the webpack.config.js, add

.enableVueLoader()

The Flex Recipe already creates a app.js for you. You can then put your vuejs code inside of there like this

'use strict';
import Vue from 'vue';

new Vue({
    el: '#app',
    data: {},
    methods: {},
    watch: {},
    components: {}
});

After running encore you can include your compiled app.js file inside of twig with the very handy twig function

{{ encore_entry_script_tags('app') }}

A detailed documentation of webpack-encore can be found here

Leave a comment