0.0.18 • Published 3 years ago

@jaqen404/vue-brass v0.0.18

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

vue-brass

brass integration for vue

brass 的 vue 插件

安装

yarn add @jaqen404/vue-brass

or

npm install @jaqen404/vue-brass

使用

// store.js
import { createVueStore } from "@jaqen404/vue-brass";
const state = {
  count: 1,
  people: {
    name: "tom",
    age: 11,
  },
};
const getters = {
  doubleCount: (state: State) => state.count * 2,
};
const mutations = {
  // 注意:mutasions方法里,不能有返回值
  add: (amount: number) => (state: any) => {
    state.count += amount;
  },
  changeName: (name: string) => (state: any) => {
    state.people.name = name;
  },
};
const actions = {
  doAsync:
    (a: number, b: number) =>
    async ({ mutations }) => {
      await new Promise((resolve: any) => {
        setTimeout(resolve, 3000);
      });
      mutations.sum(a, b);
      return a + b;
    },
};
export const useFirstStore = createVueStore(
  "firstStore",
  state,
  getters,
  mutations,
  actionss
);
<script lang="ts" setup>
import { defineComponent, ref } from "vue";
import { useFirstStore } from "../store/main";
const store = useFirstStore();
const handleClick = () => {
    store.add(1);
};
const handleClickName = () => {
  store.setState(state => {
    state.people.name += state.count;
  })
}
</script>
<template>
    <div>
        <div @click="handleClick">{{ store.doubleCount }}</div>
        <div @click="handleClickName">{{store.people.name}}</div>
        <div @click="handleClick">{{ store.count }}</div>
    <div>
</template>
0.0.13

3 years ago

0.0.14

3 years ago

0.0.15

3 years ago

0.0.16

3 years ago

0.0.17

3 years ago

0.0.18

3 years ago

0.0.10

3 years ago

0.0.11

3 years ago

0.0.12

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago