I need to get access to the data stored in canvas.js in my vue.js. For this I have to create the instance of canvas in my vue. But I have some issues with this.
I found the similar problem as mine but the answer doesnt set up for me, I also tried require. I also find some solution with ES6, but I dont use ES6, but I also tried it, not working.
This what I type in Vue.js
import Canvas from './canvas.js';
Canvas.js
export default class Canvas{
contructor(){
this.devices = ["5", "15"];
}
I wonder why does first solution didnt help me, bcz my problem is very similar. If I comment with "//" the import in Vue.js everything working fine. Maybe there are another solution without using import, but I need to have access to the data stored in Canvas.
P.s pls dont recommend to use components bcs im planning to store another class instance in devices of Canvas, and there would be too much of useless components(imho bcs im noob in vue)
UPD: My issue that the code doest not compile after "import", and I have this .
but If i put "import" to comment "//" the situation is like

UPD2: The full Vue.js file
//import Canvas from './canvas.js';
var app1 = new Vue({
el: '#vue1',
data: {
arr2: [8, 7, 6, 5]
},
methods: {
addArr1: function(num){
this.arr2.push(num)
}
}
});
canvas.js
export default class Canvas{
contructor(){
this.devices = ["5", "15"];
}
my index.html
<div id="vue1">
<ul v-for="ar in arr2">
<li>{{ ar }}</li>
</ul>
<button v-on:click="addArr1(15)">CLICK</button>
</div>
devices? Because with the current code, you have to create aCanvasinstance first.importisn't officially supported in a browser environment yet. Transpiling means taking ES6 modules (files) that useimportandexportand turning them into a singlebundle.jsfile. You seem to be using pure client-side Vue, so you can't useimportlike that. What you can do is put a<script>in your HTML and useconst Canvas = { devices: ["5", "15"] };, now your Vue script should be able to useCanvas.devices.