vue-setstate

0.0.4 • Public • Published

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

Package Sidebar

Install

npm i vue-setstate

Weekly Downloads

3

Version

0.0.4

License

MIT

Unpacked Size

12.5 kB

Total Files

14

Last publish

Collaborators

  • army-u