Vue Study
Vue3 - LifeCycle
eddie0329
2020. 10. 30. 08:50
λ°μν
π λͺ©μ°¨
- Introduction
- Life cycle in vue
- Hook inside setup
- Conclusion
- Reference
π Introduction
μλ νμΈμ. μ€λμ Vue3μ μλ‘μ΄ life cycleμ λν΄μ μμλ³΄λ €κ³ ν©λλ€. ν΄λΉ μ½λλ μ¬κΈ°μ νμΈν μ μμ΅λλ€.
π Hook inside setup
λ¨Όμ μλ‘κ² λ°λ κ²λ€μ λν΄μ Vue3 곡μ λ¬Έμμ μμΈνκ² λμμμ΅λλ€.
λ€ μ΄μ beforeCreatedλ createdλ κ΅³μ΄ μ μΈμ ν νμκ° μμ΄ μ‘μ΅λλ€.
import { onMounted, nextTick, onUpdated } from 'vue';
export default {
name: 'App',
components: {
HelloWorld
},
setup() {
console.log('before created');
console.log('created');
nextTick(() => {
console.log('nextTick');
});
onMounted(() => {
console.log('onMounted');
});
onUpdated(() => {
console.log('update');
});
// RESULT:
// before created
// created
// onMounted
// nextTick
}
};
π Conclusion
μλ‘μ΄ life-cycle-apiμ λν΄μ μμ보μμ΅λλ€. μ΄λ κ² λ§μ κΈ°λ₯λ€μ΄ μͺΌκ°μ Έμ μ¬μ¬μ©μ±μ΄ μ λ§ λ§μ΄ μ¦κ°ν κ² κ°μ΅λλ€. κ·ΈλΌ λ€μ ν¬μ€ν μμ λ§λμ~~ π
π Reference
λ°μν