Files
klienckie_stefanczyk/Lekcja_05/static/cwiczenia/lekcja-2-arrays-methods-computed/06 - computed.html
T
2026-10-26 14:34:03 +01:00

45 lines
1.1 KiB
HTML

<!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>