1.6.0 • Published 2 years ago

vue-fragment v1.6.0

Weekly downloads
57,433
License
MIT
Repository
github
Last release
2 years ago

vue-fragment npm version


what

a very candide fragment component for Vue.js

why

If you arrived here, I think you searched hard and you know why you're here.

For others, fragments are basically root-less components. They come useful in many situations where you don't want to pollute the DOM with a useless container, or you want to return many elements at once.

how

It's impossible to use functional components or slots, since Vue.js vDOM diffing has a "you should return one root element" limitation… Instead, I'm using an (internal) directive which will dump all the children of the fragment root node in its place. Since directives can manipulate DOM, we can act after rendering and bypass Vue limitation.

The component is called Fragment so you won't have to change much code when Vue3 native fragments arrive. That said, I'm not a core developer of Vue.js, and I don't have any view of their implementation. I only know what fragments are and how they should work, and did my best to reproduce it ; so it should be fine.

use

  • download the package npm i -s vue-fragment

From here, you can:

  • Plugin:

    import Fragment from 'vue-fragment'
    Vue.use(Fragment.Plugin)
    
    // or
    
    import { Plugin } from 'vue-fragment'
    Vue.use(Plugin)
    
    // …
    
    export const MyComponent {
      template: '
      <fragment>
        <input type="text" v-model="message">
        <span>{{ message }}</span>
      </fragment>
      ',
      data() { return { message: 'hello world }}
    }
  • Component:

    import { Fragment } from 'vue-fragment'
    
    export const MyComponent {
      components: { Fragment },
      template: '
      <fragment>
        <input type="text" v-model="message">
        <span>{{ message }}</span>
      </fragment>
      ',
      data() { return { message: 'hello world }}
    }
@spaceone/design-system@hn-ui/hn-uiabpx-puddingcsmf-uibpmn-editor-wjbpmn-editor-wujin@tmigone/admin-components@itnikc/legend-bpmn-editorlegend-bpmn-editor@xzwangning/qwe@xzwangning/lr-uiqwewqspaceone-console@xzwangning/l-ui@xzwangning/lr-vue-ui@xzwangning/luispaceone-dslrr-vue-uilr-vue-ui@csmf-cli/csmf-ui@nowa-zhp/uinx-tablenx-libs@tomer.yechiel/pev2gs-components2@frgr91/vue3-plugin-typescript@infinitebrahmanuniverse/nolb-vue-fhy-frontend-components-test@everything-registry/sub-chunk-3081@aqsc/form-makingas-c-vue-neo-bas-c-vue-neo@zhp-pl/ui@8n8/editor-ui@zjlabvis/common-formgorgon-ui@tvergara/vue-notion@weedx/components@baifendian/adherevhydee-ui@calipsa/vue-with-scrollbase-map-newbilld-ui@competitionlabs/rules-engine-widgetj-project-console--vej-vue-element-components@culture-connect/cc-component-libraryculqi-uimanage-sys-libscxui-vuem2-uim2-vuem2-webuim2-mobuinpm-demo-hwnstc-datasource-webnx-query-buildermysingpromyui-vuejsmyvueadmintemplatenetforce_theme@caroundsky/lemon-adminhw-vue-componentshw-vue-components2hw-base-componentsdm-color-gradient-pickerlrrr-vue-uipegasus-vue-componentspmd-mobile-componentplot-toolkit-2-testta-ui-kittulipatulipa-vuexjj-npm-demoxjjdemoonexx-form-makingyxtx-libzee-datatablesvuejs-phone-mask-inputzk-componentsuap-vuev-codyhouse-componentsv-codyhouse-componentzuse-on-demandvdrag-uivue-b-slotvue-element-pro-componentsvolumetric-datagridvue-color-gradient-pickervue-color-settingvue-component-pghvue-form-terminatorvue-hello-world-simple-test-newvue-infi-scrollervue_rt_stylevue2-ios-pwa-promptvue-mky-svgvue-page-kabobvue-multi-number-inputvue-render-slotvue-zephyrs
1.5.3

2 years ago

1.6.0

2 years ago

1.5.2

3 years ago

1.5.1

5 years ago

1.5.0

5 years ago

1.2.2

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.0

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago

0.0.1

6 years ago