๋ฐ์ํ
<!DOCTYPE html>
<head>
<title>Vue Instance Lifecycle</title>
</head>
<body>
<div id="app">
{{ message }}
</div>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script>
new Vue({
el: '#app',
data: {
message: 'Hello Vue.js!'
},
beforeCreate: function() {
console.log("beforeCreate")
},
created: function() {
console.log("created")
},
mounted: function() {
console.log("mounted")
},
updated: function() {
console.log("updated")
},
})
</script>
</body>
</html>
- message ๊ฐ์ด ๋ณ๊ฒฝ๋์์๋ Lifecycle ์์
<!DOCTYPE html>
<html lang="en">
<head>
<title>Vue Instance Lifecycle</title>
</head>
<body>
<div id="app">
{{ message }}
</div>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script>
new Vue({
el: '#app',
data: {
message: 'Hello Vue.js!'
},
beforeCreate: function() {
console.log("beforeCreate")
},
created: function() {
console.log("created")
},
mounted: function() {
console.log("mounted")
this.message = "Hello Vue!" โ
},
updated: function() {
console.log("updated")
},
})
</script>
</body>
</html>
๋ฐ์ํ
'JavaScript > Vue' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
์ธ์คํด์ค ์ ํจ ๋ฒ์์ ์ง์ญ ์ปดํฌ๋ํธ, ์ ์ญ ์ปดํฌ๋ํธ ๊ฐ ๊ด๊ณ (0) | 2022.06.05 |
---|---|
Component (0) | 2022.06.05 |
vue ๊ณต๋ถ (0) | 2022.05.15 |
[Vue.js] <style scoped> (0) | 2022.01.04 |
[Vue.js] v-model (0) | 2021.12.28 |
๋๊ธ