Skip to content

Instantly share code, notes, and snippets.

@whaaaley
Last active August 23, 2016 21:28
Show Gist options
  • Save whaaaley/4e452d92bc1034714a67e6af6996c9b1 to your computer and use it in GitHub Desktop.
Save whaaaley/4e452d92bc1034714a67e6af6996c9b1 to your computer and use it in GitHub Desktop.

Vue for Nuebs

Part 2: Importing Vue components.

1. Install the relevant preprocessors you want to use.

npm install --save-dev node-sass jade

2. Create a new Vue component file in your src directory called main.vue.

<template lang='jade'>
  div {{ msg }}
</template>

<script>
  export default {
    data () {
      return { msg: 'Hello Vue!' }
    }
  }
</script>

<style lang='scss'>
  div { color: dodgerblue; }
</style>

3. Add an import for main.vue in your index.js file and render it.

import Vue from 'vue'
import main from './main.vue'

new Vue({
  el: '#root',
  render: h => h(main)
})

4. Import your global SCSS files.

<style lang='scss'>
  @import 'variables';
  
  div { color: dodgerblue; }
</style>

5. Import other components.

<script>
  import app from './app.vue'

  export default {
    data () {
      return { msg: 'Hello Vue!' }
    },
    components: { app }
  }
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment