VueJS Lekcja 2
This commit is contained in:
1 parent
e66b5ebc22
commit
0a308d6145
10 files changed
+373
-2
No files matched your search
@@ -0,0 +1,45 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Start VueJS</title>
|
||||
<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="app">
|
||||
<p>computed w odróżnieniu od methods wykonują się tylko raz i nie używamy nawiasów podczas ich wywoływania</p>
|
||||
<h2>{{ getCar }} </h2>
|
||||
<h2>{{ getYear }} </h2>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
<script>
|
||||
|
||||
const app = Vue.createApp({
|
||||
data() {
|
||||
return {
|
||||
type: "Fiat",
|
||||
year: 1989,
|
||||
model: "Panda"
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
getCar() {
|
||||
const car = "To jest auto: " + this.type + " " + this.model;
|
||||
console.log(car);
|
||||
return car;
|
||||
},
|
||||
getYear() {
|
||||
const year = "To jest rok: " + this.year;
|
||||
console.log(year);
|
||||
return year;
|
||||
}
|
||||
}
|
||||
}).mount("#app");
|
||||
|
||||
</script>
|
||||
|
||||
</html>
|
||||
Reference in new issue
Block a user