I am new in node and vue. So I have a Vue.js application where I want to add TCP connection. But trouble is that when I require net library and trying to make tcp client - I get this error: Uncaught TypeError: net.Socket is not a constructor
. There is nothing in Google, so I hope that you will help me.
Example of my App.vue code:
<template>
<div id="app">
<test v-if = "showTest"></test>
<other v-else = "showTest"></other>
<new v-if = "showTest"></new>
<br />
<button v-on:click = "changeItems">Click me</button>
</div>
</template>
<script>
import Test from './components/test'
import Other from './components/other'
import New from './components/new'
const net = require('net')
var client = new net.Socket();
export default {
name: 'app',
components: {
Test,
Other,
New
},
data() {
return {
showTest: true,
}
},
methods: {
changeItems: function() {
setTimeout(() => {
this.showTest = !this.showTest;
console.log('Flag ', New.data().ownFlag);
New.data().ownFlag = !New.data().ownFlag;
}, 1000);
},
}
}
</script>
via Pollyflow
No comments:
Post a Comment