Compare commits

...
5 Commits
Author SHA1 Message Date
marcgauch f4babc01a9 Session 4 2023-01-23 22:00:31 +01:00
marcgauch 65869fbe87 Session 3 2023-01-18 21:58:07 +01:00
marcgauch c335f5a31f Session 2 2023-01-16 21:57:08 +01:00
marcgauch da0c4e925d Todo with ugly af filter 2023-01-12 22:22:43 +01:00
marcgauch 60b55382f8 Fixed typo in folder name 2023-01-12 22:22:19 +01:00
58 changed files with 5049 additions and 7 deletions

No files matched your search

+38
View File
@@ -0,0 +1,38 @@
const app = Vue.createApp({
data: () => ({
inputValue: "",
items: [
{ name: "aaa1", done: false },
{ name: "bbb2", done: true },
{ name: "ccc3", done: false },
],
toggle: false,
}),
methods: {
addToList() {
//this.items.push(this.inputValue) // nicht mehr brauchbar, da wir jetzt ein objekt haben
this.items.push({ name: this.inputValue, done: false });
this.inputValue = ""; //löscht das inputfeld wieder
},
deleteAll() {
this.items = [];
},
deleteItem(index) {
//https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice
this.items.splice(index, 1); // mit (index, 2) löscht es zwei elemente
},
},
computed: {
totalCompletedTasks() {
let count = 0;
for (let i = 0; i < this.items.length; i++) {
if (this.items[i].done) {
count++;
}
}
return count;
},
},
});
app.mount("#app");
File renamed without changes.
File renamed without changes.
@@ -6,7 +6,8 @@ const app = Vue.createApp({
{name: "bbb2", done: true},
{name: "ccc3", done: false}
],
toggle: false
toggle: false,
searchString: ""
}),
methods: {
addToList () {
@@ -23,6 +24,9 @@ const app = Vue.createApp({
}
},
computed: {
filteredElements () {
return this.items.filter(e => e.name.includes(this.searchString))
},
totalCompletedTasks() {
let count = 0;
for (let i = 0; i < this.items.length; i++){
@@ -0,0 +1,72 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>TITLE</title>
<link
href="https://fonts.googleapis.com/css2?family=Jost:wght@400;700&display=swap"
rel="stylesheet"
/>
<link rel="stylesheet" href="styles.css" />
<script src="https://unpkg.com/vue@next" defer></script>
<script src="app.js" defer></script>
</head>
<body>
<!--
ein todo app
+ liste (v-for, array)
+ inputfield mit item (databinding)
+ bei enter speichern und anzeigen (event)
+ items müssen gelöscht werden können (methode?)
+ todos als absolviert markieren (checkbox)
+ button clear all
+ erledigte durchstreichen
+ zählen wie viele tasks erledigt sind
reihenfolge:
1. inputfield :)
2. array erstellen
3. button erstellen
4. item hinzufügen
5. vorheriger input löschen
6. enter zum hinzufügen (GESCHAFFT DANK GOOGLEN!)
7. todos anzeigen (hämmer, aber in hässlech)
8. alles löschen button (entschäuschend einfach gewesen)
9. Spezifisches löschen (hard af)
10. checkbox hinzufügen
11: css klasse erstellen
12: style binding
-->
<section id="app">
<input
type="text"
v-model="inputValue"
@keyup.enter="addToList"
/>
<button @click="addToList">Add</button> Anzahl erledigter Tasks: {{totalCompletedTasks}}<br>
<input
type="text"
v-model="searchString"
placeholder="type to filter"
/>
<hr>
<ul>
<li v-for="(item, index) in filteredElements">
<input type="checkbox" v-model="item.done" />
<!-- geht aber ist nicht so schön
<del v-if="item.done">{{item.name}}</del>
<span v-else>{{item.name}}</span>
-->
<!-- schöner mit CSS class: ich-bin-durchgestrichen-->
<span :class="{ 'ich-bin-durchgestrichen': item.done }">{{item.name}}</span>
<button @click="deleteItem(index)">delete</button>
</li>
</ul>
<button @click="deleteAll">Delete all</button>
</section>
</body>
</html>
@@ -0,0 +1,67 @@
* {
box-sizing: border-box;
}
html {
font-family: 'Jost', sans-serif;
}
body {
margin: 0;
}
section {
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.26);
margin: 3rem;
border-radius: 10px;
padding: 1rem;
text-align: center;
}
h2 {
font-size: 2rem;
border-bottom: 4px solid #ccc;
color: #970076;
margin: 0 0 1rem 0;
}
p {
font-size: 1.25rem;
font-weight: bold;
background-color: #970076;
padding: 0.5rem;
color: white;
border-radius: 25px;
}
input {
font: inherit;
border: 1px solid #ccc;
}
input:focus {
outline: none;
border-color: #1b995e;
background-color: #d7fdeb;
}
button {
font: inherit;
cursor: pointer;
border: 1px solid #ff0077;
background-color: #ff0077;
color: white;
padding: 0.05rem 1rem;
box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.26);
}
button:hover,
button:active {
background-color: #ec3169;
border-color: #ec3169;
box-shadow: 1px 1px 4px rgba(0, 0, 0, 0.26);
}
.ich-bin-durchgestrichen {
text-decoration: line-through;
}
+30
View File
@@ -0,0 +1,30 @@
const app = Vue.createApp({
data() {
return {
tasks: [],
textfeld: "",
einblenden: true,
};
},
methods: {
addTasks() {
this.tasks.push(this.textfeld);
console.log(this.tasks);
},
einausblenden() {
this.einblenden = !this.einblenden;
},
},
computed: {
buttonCaption() {
// wenn die liste angezeigt wird (-> einblenden: true), dann gib "hide" zurück
// sonst gib "show" zurück
if (this.einblenden) {
return "hide";
} else {
return "show";
}
},
},
});
app.mount("#assignment");
+29
View File
@@ -0,0 +1,29 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>TITLE</title>
<link
href="https://fonts.googleapis.com/css2?family=Jost:wght@400;700&display=swap"
rel="stylesheet"
/>
<link rel="stylesheet" href="styles.css" />
<script src="https://unpkg.com/vue@next" defer></script>
<script src="app.js" defer></script>
</head>
<body>
<section id="assignment">
<input type="text" v-model="textfeld" />
<button @click="addTasks">Add Task</button>
<ul v-if="einblenden">
<!-- 2) Output the list of tasks here-->
<li v-for="task in tasks">{{ task }}</li>
</ul>
<p v-else>es wird nichts angezeigt...</p>
<!-- 3) When the below button is pressed, the list should be shown or hidden -->
<!-- BONUS: Also update the button caption -->
<button @click="einausblenden">{{buttonCaption}} List</button>
</section>
</body>
</html>
+64
View File
@@ -0,0 +1,64 @@
* {
box-sizing: border-box;
}
html {
font-family: 'Jost', sans-serif;
}
body {
margin: 0;
}
section {
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.26);
margin: 3rem;
border-radius: 10px;
padding: 1rem;
text-align: center;
}
h2 {
font-size: 2rem;
border-bottom: 4px solid #ccc;
color: #970076;
margin: 0 0 1rem 0;
}
p {
font-size: 1.25rem;
font-weight: bold;
background-color: #970076;
padding: 0.5rem;
color: white;
border-radius: 25px;
}
input {
font: inherit;
border: 1px solid #ccc;
}
input:focus {
outline: none;
border-color: #1b995e;
background-color: #d7fdeb;
}
button {
font: inherit;
cursor: pointer;
border: 1px solid #ff0077;
background-color: #ff0077;
color: white;
padding: 0.05rem 1rem;
box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.26);
}
button:hover,
button:active {
background-color: #ec3169;
border-color: #ec3169;
box-shadow: 1px 1px 4px rgba(0, 0, 0, 0.26);
}
+6
View File
@@ -0,0 +1,6 @@
# Q&A
## 1. Assignment 5
v-for mit ein und ausblenden button
_beantwortet in frage-1 order_
+13
View File
@@ -0,0 +1,13 @@
# Step by Step preparation for the Exam
- Download the exam.zip on your computer
- Unzip it at a place of your choice
- Open Visual Studio Code
- Go to File -> Open Folder and select the exam folder
## Steps for task-4
- Go to Terminal -> New Terminal to open the terminal
- Go to the terminal an run `cd task-4`
- run `npm install`
- run `npm run dev`
- open the given locahost address with your browser
- If you see no error everything works and you can start with the task
Binary file not shown.
+17
View File
@@ -0,0 +1,17 @@
const app = Vue.createApp({
data() {
return {
title: "Vue.js",
link: "https://de.wikipedia.org/wiki/JavaScript",
input: "",
};
},
methods: {
showAlert() {
alert("This is an alert");
},
},
computed: {},
});
app.mount("#asdfereiaicicmkdjkasekjfasdf3e");
+46
View File
@@ -0,0 +1,46 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Task 1</title>
<link rel="stylesheet" href="https://unpkg.com/chota@latest" />
<script src="https://unpkg.com/vue@latest" defer></script>
<script src="app.js" defer></script>
</head>
<body>
<section class="container" id="asdfereiaicicmkdjkasekjfasdf3e">
<h1>Task 1</h1>
<div class="card">
<header>
<!--
1. Use a data property to show the header text in <h4> (Vue.js)
-->
<h4>{{title}}</h4>
</header>
<!--
2. Use data binding for the href attribute (https://de.wikipedia.org/wiki/JavaScript)
-->
<p>
is an open-source front end
<a v-bind:href="link">JavaScript</a>
framework.
</p>
<!--
3. Output any text you type into the input field, in the <p> below the input field.
-->
<p><input type="text" v-model="input" /></p>
<p>{{input}}</p>
<footer class="is-right">
<!--
4. Use click event binding to call a method which shows an alert
Hint: to show an alert use alert('This is an alert');
-->
<button class="button primary" @click="showAlert">Alert</button>
</footer>
</div>
</section>
</body>
</html>
Binary file not shown.
+28
View File
@@ -0,0 +1,28 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules
.DS_Store
dist
dist-ssr
coverage
*.local
/cypress/videos/
/cypress/screenshots/
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
+3
View File
@@ -0,0 +1,3 @@
{
"recommendations": ["Vue.volar", "Vue.vscode-typescript-vue-plugin"]
}
+29
View File
@@ -0,0 +1,29 @@
# exam
This template should help get you started developing with Vue 3 in Vite.
## Recommended IDE Setup
[VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur) + [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin).
## Customize configuration
See [Vite Configuration Reference](https://vitejs.dev/config/).
## Project Setup
```sh
npm install
```
### Compile and Hot-Reload for Development
```sh
npm run dev
```
### Compile and Minify for Production
```sh
npm run build
```
+13
View File
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="https://unpkg.com/chota@latest">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Exam App</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.js"></script>
</body>
</html>
File diff suppressed because it is too large. Load diff
+17
View File
@@ -0,0 +1,17 @@
{
"name": "exam",
"version": "0.0.0",
"private": true,
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
},
"dependencies": {
"vue": "^3.2.45"
},
"devDependencies": {
"@vitejs/plugin-vue": "^3.2.0",
"vite": "^3.2.4"
}
}
@@ -0,0 +1,37 @@
<!--
Task: Outsource the "Articles" from this News Site in a child component including Props
for the header and Paragraph Text.
The data for this Articles should come from the Parent SFC.
-->
<template>
<section class="container" id="app">
<!-- not part of the assignment-->
<Title title="News of the day" />
<div class="row">
<div class="col">
<Article header="Winter is coming!" text="Get your gear ready." />
</div>
<div class="col">
<Article header="Vue.js" text="Version 14 out now!" />
</div>
<div class="col">
<Article header="Chur" text="Swiss town out of Cheese!" />
</div>
<div class="col">
<Article header="FHGR" text="Data leaked from University." />
</div>
</div>
</section>
</template>
<script>
import Article from "./components/Article.vue";
import Title from "./components/Title.vue";
export default {
components: {
Article,
Title,
},
};
</script>
+37
View File
@@ -0,0 +1,37 @@
<!--
Task: Outsource the "Articles" from this News Site in a child component including Props
for the header and Paragraph Text.
The data for this Articles should come from the Parent SFC.
-->
<template>
<section class="container" id="app">
<Title title="News of the day" />
<div class="row">
<div class="col" v-for="article in articles">
<Article v-bind:header="article.header" :text="article.text"></Article>
</div>
</div>
</section>
</template>
<script>
import Article from "./components/Article.vue";
import Title from "./components/Title.vue";
export default {
data() {
return {
articles: [
{ header: "Winter is coming!", text: "Get your gear ready." },
{ header: "Vue.js", text: "Version 14 out now!" },
{ header: "Chur", text: "Swiss town out of Cheese!" },
{ header: "FHGR", text: "Data leaked from University." },
],
};
},
components: {
Article,
Title,
},
};
</script>
@@ -0,0 +1,14 @@
<template>
<div class="card">
<header>
<h4>{{ header }}</h4>
</header>
<p>{{ text }}</p>
</div>
</template>
<script>
export default {
props: ["header", "text"],
};
</script>
@@ -0,0 +1,14 @@
<template>
<div>
<h1>{{ title }}</h1>
<h3>the best news</h3>
<a href="mailto:me@hotmail.com">contact me</a>
<hr />
</div>
</template>
<script>
export default {
props: ["title"],
};
</script>
+5
View File
@@ -0,0 +1,5 @@
import { createApp } from 'vue'
import App from './App.vue'
const app = createApp(App);
app.mount('#app');
@@ -0,0 +1,14 @@
import { fileURLToPath, URL } from 'node:url'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue()],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
}
})
+6
View File
@@ -0,0 +1,6 @@
{
"name": "task-4",
"lockfileVersion": 2,
"requires": true,
"packages": {}
}
+28
View File
@@ -0,0 +1,28 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules
.DS_Store
dist
dist-ssr
coverage
*.local
/cypress/videos/
/cypress/screenshots/
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
+3
View File
@@ -0,0 +1,3 @@
{
"recommendations": ["Vue.volar", "Vue.vscode-typescript-vue-plugin"]
}
+29
View File
@@ -0,0 +1,29 @@
# exam
This template should help get you started developing with Vue 3 in Vite.
## Recommended IDE Setup
[VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur) + [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin).
## Customize configuration
See [Vite Configuration Reference](https://vitejs.dev/config/).
## Project Setup
```sh
npm install
```
### Compile and Hot-Reload for Development
```sh
npm run dev
```
### Compile and Minify for Production
```sh
npm run build
```
+13
View File
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="https://unpkg.com/chota@latest">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Exam App</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.js"></script>
</body>
</html>
File diff suppressed because it is too large. Load diff
+17
View File
@@ -0,0 +1,17 @@
{
"name": "exam",
"version": "0.0.0",
"private": true,
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
},
"dependencies": {
"vue": "^3.2.45"
},
"devDependencies": {
"@vitejs/plugin-vue": "^3.2.0",
"vite": "^3.2.4"
}
}
+39
View File
@@ -0,0 +1,39 @@
<!--
Task: Outsource the "Articles" from this News Site in a child component including Props
for the header and Paragraph Text.
The data for this Articles should come from the Parent SFC.
-->
<template>
<section class="container" id="app">
<h1>News of the day</h1>
<div class="row">
<div class="col" v-for="article in articles">
<Articles :header="article.header" :text="article.text" />
</div>
</div>
</section>
</template>
<script>
import Articles from "./components/Articles.vue";
export default {
data() {
return {
articles: [
{ header: "Winter is coming!", text: "Get your gear ready." },
{ header: "Vue.js", text: "Version 14 out now!" },
{ header: "Chur", text: "Swiss town out of Cheese!" },
{ header: "FHGR", text: "Data leaked from University." },
{
header: "marc",
text: "hat auch noch was wichtiges was er sagen möchte.",
},
],
};
},
components: {
Articles,
},
};
</script>
@@ -0,0 +1,35 @@
<template>
<div class="card" :class="{ red: binIchGelesen }">
<!-- <div class="card" :class="state"></div> ez way-->
<header>
<h4>{{ header }}</h4>
</header>
<p>{{ text }}</p>
<button @click="showAlert">vorlesen</button>
</div>
</template>
<script>
export default {
props: ["header", "text"],
data() {
return {
binIchGelesen: false,
//state: "", // das hier auf red setzen ist der easy way
};
},
methods: {
showAlert() {
alert(this.header);
this.binIchGelesen = true;
//this.state = "red"; // ez way
},
},
};
</script>
<style>
.red {
background-color: red;
}
</style>
+5
View File
@@ -0,0 +1,5 @@
import { createApp } from "vue";
import App from "./App.vue";
const app = createApp(App);
app.mount("#app");
+14
View File
@@ -0,0 +1,14 @@
import { fileURLToPath, URL } from 'node:url'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue()],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
}
})
+28
View File
@@ -0,0 +1,28 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules
.DS_Store
dist
dist-ssr
coverage
*.local
/cypress/videos/
/cypress/screenshots/
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
+3
View File
@@ -0,0 +1,3 @@
{
"recommendations": ["Vue.volar", "Vue.vscode-typescript-vue-plugin"]
}
+29
View File
@@ -0,0 +1,29 @@
# exam
This template should help get you started developing with Vue 3 in Vite.
## Recommended IDE Setup
[VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur) + [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin).
## Customize configuration
See [Vite Configuration Reference](https://vitejs.dev/config/).
## Project Setup
```sh
npm install
```
### Compile and Hot-Reload for Development
```sh
npm run dev
```
### Compile and Minify for Production
```sh
npm run build
```
+13
View File
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="https://unpkg.com/chota@latest">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Exam App</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.js"></script>
</body>
</html>
+1205
View File
File diff suppressed because it is too large. Load diff
+17
View File
@@ -0,0 +1,17 @@
{
"name": "exam",
"version": "0.0.0",
"private": true,
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
},
"dependencies": {
"vue": "^3.2.45"
},
"devDependencies": {
"@vitejs/plugin-vue": "^3.2.0",
"vite": "^3.2.4"
}
}
+34
View File
@@ -0,0 +1,34 @@
<!--
Task: Outsource the "Articles" from this News Site in a child component including Props
for the header and Paragraph Text.
The data for this Articles should come from the Parent SFC.
-->
<template>
<section class="container" id="app">
<h1>News of the day</h1>
<div class="row">
<div class="col">
<Articles header="Winter is coming!" text="Get your gear ready." />
</div>
<div class="col">
<Articles header="Vue.js" text="Version 14 out now!" />
</div>
<div class="col">
<Articles header="Chur" text="Swiss town out of Cheese!" />
</div>
<div class="col">
<Articles header="FHGR" text="Data leaked from University." />
</div>
</div>
</section>
</template>
<script>
import Articles from "./components/Articles.vue";
export default {
components: {
Articles,
},
};
</script>
@@ -0,0 +1,14 @@
<template>
<div class="card">
<header>
<h4>{{ header }}</h4>
</header>
<p>{{ text }}</p>
</div>
</template>
<script>
export default {
props: ["header", "text"],
};
</script>
+5
View File
@@ -0,0 +1,5 @@
import { createApp } from "vue";
import App from "./App.vue";
const app = createApp(App);
app.mount("#app");
+14
View File
@@ -0,0 +1,14 @@
import { fileURLToPath, URL } from 'node:url'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue()],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
}
})
@@ -0,0 +1,89 @@
const app = Vue.createApp({
data() {
return {
contacts: [
{ name: "Hans", firstname: "Meier", dateOfBirth: "1967-12-15" },
{ name: "Luca", firstname: "Rudolf", dateOfBirth: "1999-01-12" },
{ name: "Laura", firstname: "Steiner", dateOfBirth: "2002-12-24" },
{ name: "Alfred", firstname: "Hauser", dateOfBirth: "1932-05-16" },
],
amountOfContacts: 4,
isVisible: false,
name: "",
firstname: "",
dateOfBirth: "",
};
},
methods: {
addContact() {
// Das folgende IF verhindert das Hinzufügen eines nicht kompletten Eintrags.
if (
this.name !== "" &&
this.firstname !== "" &&
this.dateOfBirth !== ""
) {
// Kontakt hinzufügen
this.contacts.push({
name: this.name,
firstname: this.firstname,
dateOfBirth: this.dateOfBirth,
});
// Kontaktzähler(amountOfContacts) erhöhen
this.amountOfContacts = this.amountOfContacts + 1; // (3 mal das gleiche Resultat)
//this.amountOfContacts += 1; // (3 mal das gleiche Resultat)
//this.amountOfContacts++ // (3 mal das gleiche Resultat)
// Eingaben leeren
this.name = "";
this.firstname = "";
this.dateOfBirth = "";
}
},
},
computed: {},
// mache einen watcher der uns mitteilt wenn wir 10 oder mehr contacts haben.
watch: {
/*
// für einen spezifischen verbotenen Namen
firstname() {
// wir wollen keine asdf* in unserer Adressliste
// * das ist einfach ein Beispiel
console.log("im watcher", this.newContactFirstname);
// wenn der firstname "asdf" ist soll eine Meldung (alert) kommen, das das keine gültige Eingabe ist.
if (this.firstname === "asdf") {
alert("dich wollen wir hier nicht");
}
},
*/
// wir wollen einen Fluchwortfilter beim Vornamen. Egal ob gross oder klein geschrieben
firstname() {
// verbotene Namen sind: ["marc", "andrea", "yaren", "stefanie", "stephanie", "stefani"]
const evils = [
"andrea",
"marc",
"stefani",
"stefanie",
"stephanie",
"yaren",
];
for (let i = 0; i < evils.length; i++) {
const evil = evils[i];
if (this.firstname === evil) {
alert("gtfo");
}
}
},
amountOfContacts() {
// wenn wir 7 oder mehr kontakte haben soll eine meldung(Zu oberst auf der Seite soll stehen "you're famous") erscheinen.
if (this.amountOfContacts >= 7) {
this.isVisible = true;
}
},
},
});
app.mount("#app");
@@ -0,0 +1,30 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>TITLE</title>
<link
href="https://fonts.googleapis.com/css2?family=Jost:wght@400;700&display=swap"
rel="stylesheet"
/>
<link rel="stylesheet" href="styles.css" />
<script src="https://unpkg.com/vue@next" defer></script>
<script src="app.js" defer></script>
</head>
<body>
<section id="app">
<p v-if="isVisible">YOU'RE FAMOUS</p>
<section>
Name:<input type="text" v-model="name" /><br />
Firstname:<input type="text" v-model="firstname" /><br />
Date of Birth<input type="date" v-model="dateOfBirth" /><br />
<button @click="addContact">Add to my contacts</button>
</section>
<p v-for="contact in contacts">
{{contact.firstname}}, {{contact.name}}<br />
{{contact.dateOfBirth}}
</p>
</section>
</body>
</html>
@@ -0,0 +1,64 @@
* {
box-sizing: border-box;
}
html {
font-family: 'Jost', sans-serif;
}
body {
margin: 0;
}
section {
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.26);
margin: 3rem;
border-radius: 10px;
padding: 1rem;
text-align: center;
}
h2 {
font-size: 2rem;
border-bottom: 4px solid #ccc;
color: #970076;
margin: 0 0 1rem 0;
}
p {
font-size: 1.25rem;
font-weight: bold;
background-color: #970076;
padding: 0.5rem;
color: white;
border-radius: 25px;
}
input {
font: inherit;
border: 1px solid #ccc;
}
input:focus {
outline: none;
border-color: #1b995e;
background-color: #d7fdeb;
}
button {
font: inherit;
cursor: pointer;
border: 1px solid #ff0077;
background-color: #ff0077;
color: white;
padding: 0.05rem 1rem;
box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.26);
}
button:hover,
button:active {
background-color: #ec3169;
border-color: #ec3169;
box-shadow: 1px 1px 4px rgba(0, 0, 0, 0.26);
}
@@ -0,0 +1,23 @@
/*
Das Ziel dieser Anwendung ist es:
1. Eine Speisekarte für eine Pizzaria zu haben
2. Weitere Namen hinzufügen können
*/
const app = Vue.createApp({
data() {
return {
newPizza: "",
pizzas: ["Funghi", "Napoli", "Vegetariana"],
};
},
methods: {
addPizzaName() {
//hier kommt der code wo ich eine pizza in die liste packe
this.pizzas.push(this.newPizza);
},
},
});
app.mount("#app");
@@ -0,0 +1,24 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>TITLE</title>
<link
href="https://fonts.googleapis.com/css2?family=Jost:wght@400;700&display=swap"
rel="stylesheet"
/>
<link rel="stylesheet" href="styles.css" />
<script src="https://unpkg.com/vue@next" defer></script>
<script src="app.js" defer></script>
</head>
<body>
<section id="app">
<input type="text" v-model="newPizza" />
<button @click="addPizzaName">Your new pizza</button>
<ul>
<li v-for="pizza in pizzas">{{pizza}}</li>
</ul>
</section>
</body>
</html>
@@ -0,0 +1,64 @@
* {
box-sizing: border-box;
}
html {
font-family: 'Jost', sans-serif;
}
body {
margin: 0;
}
section {
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.26);
margin: 3rem;
border-radius: 10px;
padding: 1rem;
text-align: center;
}
h2 {
font-size: 2rem;
border-bottom: 4px solid #ccc;
color: #970076;
margin: 0 0 1rem 0;
}
p {
font-size: 1.25rem;
font-weight: bold;
background-color: #970076;
padding: 0.5rem;
color: white;
border-radius: 25px;
}
input {
font: inherit;
border: 1px solid #ccc;
}
input:focus {
outline: none;
border-color: #1b995e;
background-color: #d7fdeb;
}
button {
font: inherit;
cursor: pointer;
border: 1px solid #ff0077;
background-color: #ff0077;
color: white;
padding: 0.05rem 1rem;
box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.26);
}
button:hover,
button:active {
background-color: #ec3169;
border-color: #ec3169;
box-shadow: 1px 1px 4px rgba(0, 0, 0, 0.26);
}
+90
View File
@@ -0,0 +1,90 @@
const app = Vue.createApp({
data() {
return {
target: Math.ceil(Math.random() * 101) - 1,
number: 0,
};
},
methods: {
changeNumber(num) {
this.number += num;
// erlaubt keine nummern kleiner als 0 oder grösser als 100
if (this.number < 0) {
this.number = 0;
} else if (this.number > 100) {
this.number = 100;
}
},
},
computed: {
result() {
if (this.number === this.target) {
return "Nice";
} else if (this.number < this.target) {
return "too low";
} else {
return "too high";
}
},
paraClasses() {
return {
low: this.number < this.target,
perfect: this.number === this.target,
high: this.number > this.target,
};
},
},
});
app.mount("#app");
/*
this.something = true //setzen auf true
!this.something // NOT true. ändert aber nichts da wir es nicht zuweisen
this.something = !this.something // zuerst rechts vom = NOT True. also wird FALSe zugewiesen
this.something // ist jetzt false
----
another = true
another != another -> Das ist KEINE zuweisung sondern ein Vergleich.
TRUE != TRUE -> das ist false weil TRUE ist nicht ungleich TRUE
---
const a = 3
const b = 4
const c = a + b + b
const d = a + 2 * b
console.log(c) // gibt 11 aus
console.log(d) // gibt 11 aus
----
Unterschied =, == und ===
// = weist dem ausdruck links das von rechts zu
// == vergleicht
// === vergleicht ebenfalls (aber strenger. es wird auf den Datentyp geachtet)
const a = "1"
const b = 1
const c = true
console.log(a == b) // true
console.log(a === b) // false. Weil der Datentyp ist nicht gleich. String und Nummer
console.log(a == c) // true
console.log(c == a) // true
console.log(a === c) // false. String und boolean
console.log(b == c) // true
console.log(b === c) // false. Nummer und boolean
*/
+27
View File
@@ -0,0 +1,27 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>TITLE</title>
<link
href="https://fonts.googleapis.com/css2?family=Jost:wght@400;700&display=swap"
rel="stylesheet"
/>
<link rel="stylesheet" href="styles.css" />
<script src="https://unpkg.com/vue@next" defer></script>
<script src="app.js" defer></script>
</head>
<body>
<section id="app">
<p :class="paraClasses">{{ result }}</p>
{{number}}<br /><br />
<button @click="changeNumber(-10)">- 10</button>&nbsp;
<button @click="changeNumber(-5)">- 5</button>&nbsp;
<button @click="changeNumber(-1)">- 1</button>&nbsp;
<button @click="changeNumber(1)">+ 1</button>&nbsp;
<button @click="changeNumber(5)">+ 5</button>&nbsp;
<button @click="changeNumber(10)">+ 10</button>
</section>
</body>
</html>
+72
View File
@@ -0,0 +1,72 @@
* {
box-sizing: border-box;
}
html {
font-family: 'Jost', sans-serif;
}
body {
margin: 0;
}
section {
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.26);
margin: 3rem;
border-radius: 10px;
padding: 1rem;
text-align: center;
}
h2 {
font-size: 2rem;
border-bottom: 4px solid #ccc;
color: #970076;
margin: 0 0 1rem 0;
}
p {
font-size: 1.25rem;
font-weight: bold;
padding: 0.5rem;
border-radius: 25px;
}
input {
font: inherit;
border: 1px solid #ccc;
}
input:focus {
outline: none;
border-color: #1b995e;
background-color: #d7fdeb;
}
button {
font: inherit;
cursor: pointer;
border: 1px solid #ff0077;
background-color: #ff0077;
color: white;
padding: 0.05rem 1rem;
box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.26);
}
button:hover,
button:active {
background-color: #ec3169;
border-color: #ec3169;
box-shadow: 1px 1px 4px rgba(0, 0, 0, 0.26);
}
.low {
background-color: #6874e1;
}
.high {
background-color: #fa2424;
}
.perfect {
background-color: #7ec932;
}
+7 -6
View File
@@ -1,7 +1,9 @@
const app = Vue.createApp({
data: () => ({
data() {
return {
text: "hello World",
}),
};
},
methods: {
date() {
return new Date().toLocaleDateString();
@@ -9,10 +11,9 @@ const app = Vue.createApp({
},
computed: {
shouted() {
return this.text.toUpperCase()
}
}
return this.text.toUpperCase();
},
},
});
app.mount("#app");