Answers for "vue file structure"

0

vue file structure

// file name: index.vue
// structure for vue 2
<template>
  // HTML code 
  // within one element for vue2
</template>
<script>
// js code
export default {
	components: {
      // vue component to use in html
    },
    data () {
      return{
        // all global variables should be declear here
        // this.varName to access variable
        randomVar: 12,
        randomVar2: "Suman"
      }
    },
    computed:{
      // act as variable
      // syntex will be same as function
      // return value will be stored 
    },
    methods: {
      // all global function should be declear here
      // you can use all js syntex here
    },
    mounted (){
      // all other js code to be execuated here (my suggestion)
      // this is a part of "vue-lifecycle"
      // for more details: 
      // https://vuejs.org/v2/guide/instance.html#Lifecycle-Diagram
    }
}
</script>
<style scoped>
// css code
// scoped will enclose all css code within this vue file
</style>
Posted by: Guest on July-21-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language