s5e75 lifecycle
This commit is contained in:
parent
0be4aad7da
commit
8106085e2d
|
@ -1,10 +1,35 @@
|
|||
var app = new Vue({
|
||||
el: '#app',
|
||||
data: {
|
||||
ingredients: ['meat', 'fruit', 'cookies'],
|
||||
persons: [
|
||||
{name: "Max", age: 33, color: "red"},
|
||||
{name: "Tyrel", age: 30, color: "blue"},
|
||||
]
|
||||
title: "The VueJS nstance"
|
||||
},
|
||||
beforeCreate(){
|
||||
console.log("Created");
|
||||
},
|
||||
created(){
|
||||
console.log("created");
|
||||
},
|
||||
beforeMount(){
|
||||
console.log("beforeMount");
|
||||
},
|
||||
mounted(){
|
||||
console.log("mounted");
|
||||
},
|
||||
beforeUpdate(){
|
||||
console.log("before update");
|
||||
},
|
||||
updated(){
|
||||
console.log("updated");
|
||||
},
|
||||
beforeDestroy(){
|
||||
console.log("before destroy");
|
||||
},
|
||||
destroyed(){
|
||||
console.log("destroyed");
|
||||
},
|
||||
methods:{
|
||||
destroy(){
|
||||
this.$destroy();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -7,34 +7,9 @@
|
|||
</head>
|
||||
<body>
|
||||
<div id='app'>
|
||||
<ul>
|
||||
<li v-for="(ingredient, i) in ingredients" :key="ingredient">
|
||||
({{i+1}}) {{ ingredient }}
|
||||
</li>
|
||||
</ul>
|
||||
<button @click="ingredients.push('spices')"> Add New</button>
|
||||
|
||||
<hr>
|
||||
<template v-for="(ingredient, index) in ingredients">
|
||||
<h1>{{ingredient}}</h1>
|
||||
<p>{{index}}</p>
|
||||
</template>
|
||||
<hr>
|
||||
|
||||
<ul>
|
||||
|
||||
<li v-for="person in persons">
|
||||
<div v-for="(value, key, index) in person">
|
||||
{{key}}: {{value}} - {{index}}
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
<hr>
|
||||
|
||||
<span v-for="n in 10">{{n}} </span>
|
||||
|
||||
|
||||
|
||||
{{title}}
|
||||
<button @click="title = 'changed'">click</button>
|
||||
<button @click="destroy"> destroy </button>
|
||||
</div>
|
||||
<script src="app.js" charset="utf-8"></script>
|
||||
</body>
|
||||
|
|
Loading…
Reference in New Issue
Block a user