How can I retrieve the dimensions of an image located in the asset folder of my project?
I attempted to do so within the mounted() hook:
let grid = new Image()
grid.src = require('../../assets/sprites/grid.png');
console.log(grid.naturalWidth, grid.naturalHeight)
However, I consistently get 0 instead of the expected 3030px.
EDIT:
I have found a partial solution, but it's not fully working.
The value for this.gridPattern is defined in the data object above, but when I try to re-assign its value, it remains at 0.
let grid = new Image()
grid.src = require('../../assets/sprites/grid_pathern.png');
grid.onload = () => {
console.log(`the image dimensions are ${grid.width}x${grid.height}`);
this.gridPattern = {width:grid.width,height:grid.height}
console.log(this.gridPattern)
};