Vue setstate

Optimizing Vue big data processing

Version: 0.0.4 Updated: 03/15/2018

By: Army-U License: MIT

Downloads Last 30 Days: 32

Install

npm i vue-setstate
yarn add vue-setstate

Repository: https://github.com/Army-U/vue-setstate

CDNs

bundle.run: https://bundle.run/vue-setstate

jsDelivr: https://cdn.jsdelivr.net/npm/vue-setstate

unpkg: https://unpkg.com/vue-setstate

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

Categories: Vue js