Bits and Pieces

Insightful articles, step-by-step tutorials, and the latest news on full-stack composable software development

Follow publication

Sharing and Reusing Vue Mixins in the Cloud with Bit.dev

Lotanna Nwose
Bits and Pieces
Published in
7 min readMay 20, 2019

--

Bit.dev

Before you start

 node -v
npm install bit-bin -g
npm uninstall -g vue-cli
npm install -g @vue/cli
npm install

What are Vue Mixins

Demo

4 Stages of Vue Mixins creation

Creating a Mixin file

Importing the Mixin file

import clickMixin from ‘../Mixins/clickMixin’

Removing repeated logic

// remove this code block and the comma before it.methods: {clicked(value){alert(value);}}

Register the Mixin

npm run serve

The Limitations of Vue Mixins

Introducing Bit.dev

Getting started

npm install bit-bin -g

Initializing Bit

bit init
successfully initialized a bit workspace.

Tracking Components

bit add src/Mixins/*
tracking component click-mixin:

Tagging Component Version

bit tag --all 1.0.0
1 component(s) tagged | 1 added, 0 changed, 0 auto-tagged
added components: click-mixin@1.0.0

Export the components

bit export user-name.collection-name
Bit repository

Using Mixins in other projects

npm install @bit/viclotana.vue_collection.click-mixin
<template><div><button v-on:click=”clicked(‘you just clicked on button 2’)”>Button 2</button></div></template><script>import clickMixin from ‘@bit/viclotana.vue_collection.click-mixin’export default {name: ‘Modal’,mixins: [clickMixin]}</script>

Conclusion

Learn More

--

--

Published in Bits and Pieces

Insightful articles, step-by-step tutorials, and the latest news on full-stack composable software development

Written by Lotanna Nwose

Helping Startups with Webhooks management at Convoy so they can focus on their core product offerings. Twitter:@viclotana

Responses (2)