1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
| <!DOCTYPE html> <html>
<head> <script src="http://vuejs.org/js/vue.js"></script> <meta charset="utf-8"> <title>Vue 生命周期函数</title> </head>
<body> <div id="app">
</div> <script> var vm = new Vue({ el: "#app", template: "<div>{{test}}</div>", data: { test: "Hello World" }, beforeCreate: function () { console.log("beforeCreate") }, created: function () { console.log("created") }, beforeMount: function () { console.log(this.$el) console.log("beforeMount") }, mounted: function () { console.log(this.$el) console.log("mounted") }, beforeDestroy: function () { console.log("beforeDestroy") }, destroyed: function () { console.log("destroyed") }, beforeUpdate: function () { console.log("beforeUpdate") }, updated: function () { console.log("updated") } }) </script> </body>
</html>
|