component model

This commit is contained in:
VictoriaPresnyakova 2023-05-01 15:18:58 +04:00
parent 444d226184
commit 75cfa2156f
2 changed files with 31 additions and 9 deletions

View File

@ -2,17 +2,13 @@
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="node_modules/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="node_modules/@fortawesome/fontawesome-free/css/all.min.css" rel="stylesheet">
<link rel="stylesheet" href="./src/css/style.css">
<link rel="stylesheet" href="/node_modules/bootstrap/dist/css/bootstrap.min.css">
<title>Vite App</title>
</head>
<body class="d-flex flex-column h-100">
<div id="app">
</div>
<body>
<div id="app"></div>
<script type="module" src="/node_modules/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
<script type="module" src="/src/main.js"></script>
<script src="node_modules/bootstrap/dist/js/bootstrap.min.js"></script>
</body>
</html>

View File

@ -0,0 +1,26 @@
export default class Component {
constructor(data) {
this._id = data?.id;
this._amount = data?.amount;
this._favorIds = data?._favorIds;
}
get id() {
return this._id;
}
get amount() {
return this._amount;
}
set amount(value) {
if (typeof value !== 'string' || value === null || value.length == 0) {
throw 'New amount value ' + value + ' is not a string or empty';
}
this._number = value;
}
get favorIds() {
return this._favorIds;
}
}