45 lines
1.1 KiB
HTML
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> |