Let Vue methods support return Promise
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
dist feat: test Mar 14, 2017
src feat: test Mar 14, 2017
test feat:test Mar 14, 2017
.eslintrc.js fix:test doc Mar 1, 2017
.travis.yml fix:test Mar 1, 2017
README.md doc:update Mar 29, 2017
_config.yml Set theme jekyll-theme-cayman Mar 29, 2017
gulpfile.js feat:test Mar 3, 2017
package.json doc:update Mar 29, 2017

README.md

Build Status dependencies Status devDependencies Status Known Vulnerabilities npm npm

vue-methods-promise

Let Vue methods support promise

Usage

npm install --save vue-methods-promise
// Installation
import Vue from 'vue'
import vueMethodsPromise from 'vue-methods-promise'

Vue.use(vueMethodsPromise, {
  hookName: '$promise', // Component default hook name
  promise: (mp) => { // Promise callback
    mp
      .then((function (res) {
        console.log(res)
      })
      .catch(function (err) {
        console.log(err.msg) // Test error
      })
  }
})

// Usage
export default {
  mounted () {
    this.test()
  },
  methods: { // All return Promise type, will be dealt with
    test () {
      return Promise.reject(new Error({ msg: 'Test error' }))
    }
  }
}