🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

@vueblocks/vue-use-vuex

Package Overview
Dependencies
Maintainers
3
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vueblocks/vue-use-vuex

Use Vuex With Composition API Easily.

0.1.6
Source
npm
Version published
Weekly downloads
1.1K
2.9%
Maintainers
3
Weekly downloads
 
Created
Source

@vueblocks/vue-use-vuex

Use Vuex With Composition API Easily.

Install

yarn add @vueblocks/vue-use-vuex

Usage

useVuex utilities just similar with Vuex Component Binding Helpers

It export these utilities:

  • useState
  • useGetters
  • useMutations
  • useActions

useState

import { useVuex } from '@vueblocks/vue-use-vuex'

export default {
  ...
  setup () {
    const { useState } = useVuex()

    // 写法1: 传字符串参数 'language' 等同于 `state => state.language`
    const localState = useState('global', {
      theme: 'theme',
      lang: 'lang'
    })

    // 写法2: 箭头函数可使代码更简练
    const localState = useState('global', {
      theme: state => state.theme,
      lang: state => state.lang
    })

    // 写法3: 常规函数用于计算,等同于箭头函数
    const localState = useState('global', {
      customTheme (state) {
        return 'custom' + state.theme
      }
    })

    // 写法4: 直接映射节点名称相同的计算属性
    const localState = useState('global', [
      'theme',
      'lang'
    ])
  }
  ...
}

License

MIT @xiaoluoboding

Keywords

vue

FAQs

Package last updated on 03 Dec 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts