Are you first timer at lazacode.org? Why not join us and start exchange your programming knowledge with everyone. Register today!

Vue - Component code structure

0 votes
34 views
added Jun 29, 2018 in Vue by LC Marshal Captain (25,840 points)
edited Jul 13, 2018 by LC Marshal
|- src/
  |- router/ 
  |- scss/
  |- App.vue 
  |- main.js
      Vue.component('modal', {
        template: '#modal-template'
      })
  |- components/
    |- MainPanel.vue (show only trigger button)
       <template>
          <button class="btn btn-primary btn-block" id="show-modal" @click="showModal = true">Buy</button>
          <modal v-if="showModal" @close="showModal = false">
            <h3 slot="header">Header of modal</h3>
          </modal> 
       </template>
 
        <script>
        import Modal from './Modal.vue';
 
        export default {
            components: {
              Modal
          },
 
          data () {
            return {
              showModal: false
            }
          }
        }
        </script>
    |- Modal.vue (the modal component)
        <template>
          <div id="modal-template">
            <transition name="modal">
              <div class="modal-mask">
                <div class="modal-wrapper">
                  <div class="modal-container">
 
                    <div class="modal-header">
                      <slot name="header">
                        default header
                      </slot>
                    </div>
 
                    <div class="modal-body">
                      <slot name="body">
                        default body
                      </slot>
                    </div>
 
                    <div class="modal-footer">
                      <slot name="footer">
                        default footer
                        <button class="modal-default-button" @click="$emit('close')">
                          OK
                        </button>
                      </slot>
                    </div>
                  </div>
                </div>
              </div>
            </transition>
             
          </div>
        </template>
 
    <script>
    export default {
 
      data () {
        return {
        }
      }
    }
    </script>
       
|- dist/
  |- index.html
  |- static/
    |- css/
    |- fonts/
    |- images/
    |- js/
 
|- static/ (for gulp)
      |- css/
      |- fonts/
      |- images/
|- gulpfile.js
|- node_modules/
|- package.json

Please log in or register to response this reference.

lazacode.org - Malaysia's programming knowledge sharing platform, where everyone can share their finding as reference to others.
...