86 lines
2.0 KiB
HTML
86 lines
2.0 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="pl">
|
|
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Lekcja 3</title>
|
|
<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
|
|
<style>
|
|
table {
|
|
border-collapse: collapse;
|
|
}
|
|
|
|
td {
|
|
border: 1px solid black;
|
|
width: 2rem;
|
|
height: 2rem;
|
|
text-align: center;
|
|
user-select: none;
|
|
}
|
|
|
|
td[disabled='false'] {
|
|
background-color: cornflowerblue;
|
|
cursor: pointer;
|
|
}
|
|
</style>
|
|
</head>
|
|
|
|
<body>
|
|
<div id="app">
|
|
<h2>select | disabled</h2>
|
|
<select v-model="selection">
|
|
<option selected>0</option>
|
|
<option v-for="c in criteria">{{ c }}</option>
|
|
</select>
|
|
|
|
<br><br>
|
|
|
|
<table>
|
|
<tr v-for="row in array">
|
|
<td v-for="col in row" @click="td_alert" v-bind:disabled="equ(col, selection)">{{ col }}</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
</body>
|
|
|
|
<script>
|
|
|
|
const app = Vue.createApp({
|
|
data() {
|
|
return {
|
|
selection: 0,
|
|
array: [
|
|
[1, 2, 3, 3, 3],
|
|
[4, 4, 4, 7, 1],
|
|
[2, 3, 3, 2, 1],
|
|
[5, 5, 6, 4, 3],
|
|
[1, 5, 1, 2, 5]
|
|
]
|
|
}
|
|
},
|
|
methods: {
|
|
td_alert(e) {
|
|
if (e.target.getAttribute("disabled") == 'false') {
|
|
alert("text in button = " + e.target.innerText);
|
|
}
|
|
},
|
|
equ(p, q) { return p != q }
|
|
},
|
|
computed: {
|
|
criteria() {
|
|
output = [];
|
|
set = new Set(this.array.flat());
|
|
|
|
set.forEach(e => {
|
|
output.push(e);
|
|
});
|
|
|
|
return output.sort();
|
|
}
|
|
}
|
|
}).mount("#app");
|
|
|
|
</script>
|
|
|
|
</html> |