A simple Vue plugin to augment your Vue instance methods with custom ones
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
dist
src
.babelrc
.eslintignore
.eslintrc.js
.gitignore
.npmignore
LICENSE
README.md
package.json
rollup.config.esm.js
rollup.config.umd.js
rollup.config.umd.min.js
yarn.lock

README.md

Vue Methodly

A simple Vue plugin to augment your Vue instance methods with custom ones

Install

NPM/Yarn

npm install vue-methodly --save

or

yarn add vue-methodly --save

Browser

<script src="https://unpkg.com/vue-methodly"></script>

Usage

Webpack

import VueMethodly from 'vue-methodly'
...
Vue.use(VueMethodly, {
  methods: [
    {
      // the name of your custom method
      name: 'myCustomMethod',

      // the native hook on which to execute
      hook: 'mounted'
    },
    ...
  ]
})
...
// some component
...
export default {
  ...
  // gets executed before the native mounted() hook
  myCustomMethod () {
    // whatever you like here
  },
  ...
}
...

Browser

Vue.use(VueMethodly, {
  methods: [
    {
      // the name of your custom method
      name: 'myCustomMethod',

      // the hook before which to execute
      hook: 'mounted'
    },
    ...
  ]
})
Vue.component('MyComponent', {
  ...
  // gets executed before the native mounted() hook
  myCustomMethod () {
    // whatever you like here
  },
  ...
})

Example

https://jsfiddle.net/yprbeh5f/