VueJS lekcja 4 do dokończenia
This commit is contained in:
1 parent
58990da7c8
commit
b89a51bd40
6 files changed
+480
No files matched your search
@@ -0,0 +1,53 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="pl">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Lekcja 4</title>
|
||||
<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="app">
|
||||
<input type="text" v-model="str">
|
||||
|
||||
<br><br>
|
||||
|
||||
<div v-for="word in word_array()"
|
||||
style="float: left; background-color: lightgray; padding: 1rem; margin: 1rem;">
|
||||
<div v-for="letter in word"
|
||||
style="float: left; font-family: monospace; color: brown; margin: 1rem; background-color: skyblue; padding: 1rem; font-size: 2rem;">
|
||||
{{ letter }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
<script>
|
||||
const app = Vue.createApp({
|
||||
data() {
|
||||
return {
|
||||
str: ''
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
word_array() {
|
||||
let str = this.str;
|
||||
let words = str.trim().split(" ");
|
||||
|
||||
for (let i = 0; i < words.length; i++) {
|
||||
words[i] = words[i].split('');
|
||||
}
|
||||
|
||||
console.log(words)
|
||||
if (words[0].length == 0) { return undefined; }
|
||||
|
||||
return words;
|
||||
}
|
||||
}
|
||||
}).mount("#app");
|
||||
|
||||
</script>
|
||||
|
||||
</html>
|
||||
Reference in new issue
Block a user