Skip to content

Instantly share code, notes, and snippets.

@lilgallon
Created November 20, 2019 04:09
Show Gist options
  • Save lilgallon/ffe804de63a1d5c8d1a684793441665f to your computer and use it in GitHub Desktop.
Save lilgallon/ffe804de63a1d5c8d1a684793441665f to your computer and use it in GitHub Desktop.
Vue.js cheatsheet
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
<script src="js/app.js"></script>
new Vue({
    el: '#id',
    data: {
        // ...
    },
    methods: {
        fct: function () {
            // ...
        }
    }
})
<div id="app">
    <!-- everything related to el: '#id' goes here -->
</div>
  • v-bind => :
  • :href="var"
  • v-if="var"
  • v-show="var": diff with if -> show keeps the HTML code but with display: none whereas if deletes it
  • v-else
  • v-for="{person in people}" then use {{ person }}
  • v-on:click="method" = @click="method" bc v-on = @
  • v-model="var"
  • v-model="var" :true-value:="valIfTrue" :false-value:"valIfFalse
  • :class="bool ? true : false"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment