0.0.4 • Published 6 years ago

vue-setstate v0.0.4

Weekly downloads
11
License
MIT
Repository
github
Last release
6 years ago

vue-setState Build Status npm package

Using React style setState method in Vue, Apply to optimize rendering speed of big data

Install

$ npm i vue-setstate -S

CDN: UNPKG | jsDelivr

Usage

import Vue from 'vue'
import setState from 'vue-setstate'

Vue.use(setState)

Then in your component:

<script>
export default {
  state: {
    // your data here
    name: 'tom'
  },

  methods: {
    changeMyName () {
      this.setState({ name: 'mary' })
    },
    changeMyNameWithFunctionalParam () {
      this.setState(({ name }) => ({
        name: `Hi ${name}`
      }))
    }
  }
}
</script>

Warning: state is not reactive!, you must use setState method if you want to change the view.

License

MIT

Copyright (c) 2017-present, Army-U

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago