Skip to content
This repository has been archived by the owner on Feb 5, 2020. It is now read-only.

MoYummy/vue-top-down

Repository files navigation

vue-top-down

Build Status

NPM

With this, you can mount Vue components on some of the elements on a raw html as template, with original DOM hierarchy preserved.

Check out demo.

Usage

import { VueTopDown, VTDConstants as VTD } from 'vue-top-down'
import OneComponent from 'path/to/one/component'

const StructComp = {
  mixins: [VueTopDown],
  components: {
    OneComponent
  },
  data () {
    return {
      [VTD.ROOT]: '.selector.of.hosting.element', // in case you want to skip some dom node levels
      [VTD.MAPPING]: {
        '.selector.for.one.component': OneComponent
      }
    }
  }
}
import { VueTopDownItem } from 'vue-top-down'

export default {
  name: 'OneComponent',
  mixins: [VueTopDownItem], // with this, you can handle 'clazz' / 'outerHTML'
  inheritAttrs: false
}