var app = new Vue({
el: '#app',
data: {
elements : {
elOne : {
dH:"",
S:"",
a:"",
b:"",
c:""
},
elTwo : {
dH:"",
S:"",
a:"",
b:"",
c:""
},
elThree : {
dH:"",
S:"",
a:"",
b:"",
c:""
},
elFour : {
dH:"",
S:"",
a:"",
b:"",
c:""
}
}
},
methods: {
sendData: function () { // данные для расчетов
const str = JSON.stringify(this.elements);
// console.log(str )
axios.post('http://localhost:8081/demo/', str)
.then((response) => {
console.log(response);
})
.catch((error) => {
console.log(error);
});
<table>
<!--
one element -->
<tr>
<td>
<input type="" name="" v-model="elements.elOne.dH">
</td>
<td>
<input type="" name="" v-model="elements.elOne.S">
</td>
<td>
<input type="" name="" v-model="elements.elOne.a">
</td>
<td>
<input type="" name="" v-model="elements.elOne.b">
</td>
<td>
<input type="" name="" v-model="elements.elOne.c">
</td>
</tr>
<!--
two element
-->
<tr>
<td>
<input type="" name="" v-model="elements.elTwo.dH">
</td>
<td>
<input type="" name="" v-model="elements.elTwo.S">
</td>
<td>
<input type="" name="" v-model="elements.elTwo.a">
</td>
<td>
<input type="" name="" v-model="elements.elTwo.b">
</td>
<td>
<input type="" name="" v-model="elements.elTwo.c">
</td>
</tr>
<!--
Three element
-->
<tr>
<td>
<input type="" name="" v-model="elements.elThree.dH">
</td>
<td>
<input type="" name="" v-model="elements.elThree.S">
</td>
<td>
<input type="" name="" v-model="elements.elThree.a">
</td>
<td>
<input type="" name="" v-model="elements.elThree.b">
</td>
<td>
<input type="" name="" v-model="elements.elThree.c">
</td>
</tr>
<!--
end element
-->
<tr>
<td>
<input type="" name="" v-model="elements.elFour.dH">
</td>
<td>
<input type="" name="" v-model="elements.elFour.S">
</td>
<td>
<input type="" name="" v-model="elements.elFour.a">
</td>
<td>
<input type="" name="" v-model="elements.elFour.b">
</td>
<td>
<input type="" name="" v-model="elements.elFour.c">
</td>
</tr>
</table>
var express = require("express");
var bodyParser = require("body-parser");
var fs = require('fs');
var app = express();
// создаем парсер для данных application/x-www-form-urlencoded
var urlencodedParser = bodyParser.urlencoded({extended: false});
app.use(express.static(__dirname + "/public"));
app.post("/", urlencodedParser, function (request, response) {
if(!request.body) return response.sendStatus(400);
console.log(request.body);
// преобразуем данные в json
var str = JSON.stringify(request.body);
// записываем данные в json
fs.writeFileSync('test.json', str);
// отправляем ответ
// response.send(`${str}`);
});
app.listen(8081);
console.log ('http://localhost:8081' )