دورة VUEJS للمبتدئين الدرس الرابع
1- DIRECTIVE V-FOR ف VUE JS
//main.js
new Vue({
el : '#app',
data : {
names : ['samadi','amine','halim','karim']
}
});
2- عرض الأسماء بل boucle v-for
<!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">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<title>Vue js for beginners</title>
<style>
</style>
</head>
<body>
<div id="app">
<div class="container">
<div class="form-group">
<ul class="list-group">
<li class="list-group-item" v-for="name in names">{{name}}</li>
</ul>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script src="main.js"></script>
</body>
</html>
3- التعامل مع les méthodes ف vue js
//main.js
new Vue({
el : '#app',
data : {
names : ['samadi','amine','halim','karim']
},
methods : {
addName(){
this.names.push('jamal');
}
}
});
4- التعامل مع les méthodes ف vue js تتمة
<!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">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<title>Vue js for beginners</title>
<style>
</style>
</head>
<body>
<div id="app">
<div class="container">
<div class="form-group">
<button class="btn btn-primary" v-on:click="addName">click</button>
<ul class="list-group">
<li class="list-group-item" v-for="name in names">{{name}}</li>
</ul>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script src="main.js"></script>
</body>
</html>