mirror of
https://github.com/WeBankFinTech/fes.js.git
synced 2025-10-15 20:18:49 +08:00
* feat: script setup 支持 defineRouteMeta (#144) * chore(release): publish - @fesjs/preset-built-in@2.1.4 - @fesjs/fes@2.1.4 * fix: 打开相同path的链接会更新route & 第一次打开会触发onActivated (#145) * fix: 打开相同path的链接会更新route & 第一次打开会触发onActivated * fix: 优化 * chore(release): publish - @fesjs/plugin-layout@4.2.3 Co-authored-by: qlin <haizekuo@gmail.com>
75 lines
2.0 KiB
Vue
75 lines
2.0 KiB
Vue
<template>
|
||
<div class="page">
|
||
<h4>Vuex</h4>
|
||
<input />
|
||
<div>
|
||
<button @click="increment">click me:{{ doubleCount }}</button>
|
||
</div>
|
||
<div>
|
||
<button :disabled="disabled" @click="login">async login</button>
|
||
</div>
|
||
<div>
|
||
<button @click="fooBarIncrement">foo/bar:{{ fooBarDoubleCount }}</button>
|
||
</div>
|
||
<div>{{ address }}</div>
|
||
</div>
|
||
</template>
|
||
<config>
|
||
{
|
||
"name": "store",
|
||
"title": "$store",
|
||
"keep-alive": true
|
||
}
|
||
</config>
|
||
<script>
|
||
import { computed, ref, onMounted, onUnmounted, onActivated, onDeactivated } from 'vue';
|
||
import { useStore } from 'vuex';
|
||
import { MUTATION_TYPES, GETTER_TYPES, ACTION_TYPES } from '@fesjs/fes';
|
||
|
||
export default {
|
||
setup() {
|
||
console.log('store.vue');
|
||
const store = useStore();
|
||
console.log('store==>', store);
|
||
const disabled = ref(false);
|
||
|
||
onMounted(() => {
|
||
console.log('onMounted');
|
||
});
|
||
|
||
onUnmounted(() => {
|
||
console.log('onUnmounted');
|
||
});
|
||
|
||
onActivated(() => {
|
||
console.log('onActivated');
|
||
});
|
||
|
||
onDeactivated(() => {
|
||
console.log('onDeactivated');
|
||
});
|
||
|
||
return {
|
||
address: computed(() => store.getters[GETTER_TYPES.user.address]),
|
||
doubleCount: computed(() => store.getters[GETTER_TYPES.counter.doubleCount]),
|
||
disabled,
|
||
increment: () => store.commit(MUTATION_TYPES.counter.increment),
|
||
login: () => {
|
||
disabled.value = true;
|
||
store.dispatch(ACTION_TYPES.user.login).then((res) => {
|
||
// eslint-disable-next-line no-alert
|
||
window.alert(res);
|
||
disabled.value = false;
|
||
});
|
||
},
|
||
fooBarIncrement: () => store.commit(MUTATION_TYPES.fooBar.increment),
|
||
fooBarDoubleCount: computed(() => store.getters[GETTER_TYPES.fooBar.doubleCount]),
|
||
};
|
||
},
|
||
};
|
||
</script>
|
||
<style scoped>
|
||
.page {
|
||
}
|
||
</style>
|