11 changed files with 104 additions and 47 deletions
@ -1,40 +0,0 @@ |
|||||||
<script setup> |
|
||||||
import { ref } from 'vue' |
|
||||||
|
|
||||||
defineProps({ |
|
||||||
msg: String, |
|
||||||
}) |
|
||||||
|
|
||||||
const count = ref(0) |
|
||||||
</script> |
|
||||||
|
|
||||||
<template> |
|
||||||
<h1>{{ msg }}</h1> |
|
||||||
|
|
||||||
<div class="card"> |
|
||||||
<button type="button" @click="count++">count is {{ count }}</button> |
|
||||||
<p> |
|
||||||
Edit |
|
||||||
<code>components/HelloWorld.vue</code> to test HMR |
|
||||||
</p> |
|
||||||
</div> |
|
||||||
|
|
||||||
<p> |
|
||||||
Check out |
|
||||||
<a href="https://vuejs.org/guide/quick-start.html#local" target="_blank" |
|
||||||
>create-vue</a |
|
||||||
>, the official Vue + Vite starter |
|
||||||
</p> |
|
||||||
<p> |
|
||||||
Install |
|
||||||
<a href="https://github.com/vuejs/language-tools" target="_blank">Volar</a> |
|
||||||
in your IDE for a better DX |
|
||||||
</p> |
|
||||||
<p class="read-the-docs">Click on the Vite and Vue logos to learn more</p> |
|
||||||
</template> |
|
||||||
|
|
||||||
<style scoped> |
|
||||||
.read-the-docs { |
|
||||||
color: #888; |
|
||||||
} |
|
||||||
</style> |
|
||||||
@ -0,0 +1,16 @@ |
|||||||
|
const state = { |
||||||
|
isLogin: false, |
||||||
|
successMessage: '' |
||||||
|
}; |
||||||
|
|
||||||
|
const mutations = { |
||||||
|
login(state) { |
||||||
|
state.isLogin = true; |
||||||
|
}, |
||||||
|
logout(state) { |
||||||
|
state.isLogin = false; |
||||||
|
}, |
||||||
|
setSuccessMessage(state, message) { |
||||||
|
state.successMessage = message; |
||||||
|
} |
||||||
|
};
|
||||||
@ -0,0 +1,19 @@ |
|||||||
|
import { createStore } from "vuex"; |
||||||
|
|
||||||
|
// 实例化一个store对象
|
||||||
|
|
||||||
|
const store = createStore({ |
||||||
|
state() { |
||||||
|
return { |
||||||
|
count: 0 |
||||||
|
} |
||||||
|
}, |
||||||
|
mutations: { |
||||||
|
increment(state) { |
||||||
|
state.count++ |
||||||
|
} |
||||||
|
} |
||||||
|
}) |
||||||
|
|
||||||
|
|
||||||
|
export default store |
||||||
@ -0,0 +1,31 @@ |
|||||||
|
<template> |
||||||
|
<div class="success-message"> |
||||||
|
{{ message }} |
||||||
|
</div> |
||||||
|
</template> |
||||||
|
|
||||||
|
<script> |
||||||
|
export default { |
||||||
|
props: { |
||||||
|
message: String |
||||||
|
} |
||||||
|
}; |
||||||
|
</script> |
||||||
|
|
||||||
|
<style scoped> |
||||||
|
.success-message { |
||||||
|
position: fixed; |
||||||
|
top: 20px; |
||||||
|
right: -200px; |
||||||
|
padding: 10px 20px; |
||||||
|
border-radius: 5px; |
||||||
|
background-color: #67C23A; |
||||||
|
color: #fff; |
||||||
|
transition: all .4s ease-in-out; |
||||||
|
} |
||||||
|
|
||||||
|
.success-message.show { |
||||||
|
right: 20px; |
||||||
|
} |
||||||
|
</style> |
||||||
|
|
||||||
Loading…
Reference in new issue