Created
August 11, 2018 06:13
-
-
Save devils-ey3/5ec85ff1fc936e607faa92590959b8ba to your computer and use it in GitHub Desktop.
Vue life cycle cheat sheet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<script src="vue.js"></script> | |
<title>Document</title> | |
</head> | |
<body> | |
This is html dom | |
<div id="app"> | |
{{title}} | |
<button @click="title = 'Changed'">Update Title</button> | |
<button @click="destroy">Destroy</button> | |
</div> | |
</body> | |
</html> | |
<script> | |
new Vue({ | |
el: '#app', | |
data: { | |
title: 'The VueJS Instance' | |
}, | |
beforeCreate: function() { | |
alert('beforeCreate()'); | |
}, | |
created: function() { | |
alert('created()'); | |
}, | |
beforeMount: function() { | |
alert('beforeMount()'); | |
}, | |
mounted: function() { | |
alert('mounted()'); | |
}, | |
beforeUpdate: function() { | |
alert('beforeUpdate()'); | |
}, | |
updated: function() { | |
alert('updated()'); | |
}, | |
beforeDestroy: function() { | |
alert('beforeDestroy()'); | |
}, | |
destroyed: function() { | |
alert('destroyed()'); | |
}, | |
methods: { | |
destroy: function() { | |
this.$destroy(); | |
} | |
} | |
}) | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment