vue3生命周期
作者:
念灬 | 来源:发表于
2022-01-04 10:13 被阅读0次
转自https://www.jianshu.com/p/a42f0dd3b47e
import {defineComponent} from 'vue'
import {useStore} from 'vuex'
export default defineComponent({
name: "login",
setup() {
onBeforeMount() // 组件挂在到页面之前执行。
onMounted() // 组件挂在到页面之后执行。
onBeforeUpdate() // 在组件更新之前执行。
onUpdated() // 在组件更新之后执行。
onBeforeUnmount() // 在组件卸载之前执行。
onUnmounted() // 在组件卸载之后执行。
onDeactivated() // 在组件切换中老组件消失的时候执行。
const store = useStore()
const login = () => {
store.dispatch('user/login', '')
.then((res) => {
console.log(res);
})
}
return {
login
}
}
})
本文标题:vue3生命周期
本文链接:https://www.haomeiwen.com/subject/qwlqcrtx.html
网友评论