I want to view a tiff file in a web page, I can finish it with test.html, but I need to do it in a vue file, how can I do that? and I can't know what the exact content in the tiff.js[![enter image description here][1]][1]
<script src="./jquery-2.0.3.min.js"></script>
<script src="./bootstrap.min.js"></script>
<script src="./src/assets/js/tiff.js"></script>
<script type="text/javascript">$(function () {
function show(file) {
var reader = new FileReader();
reader.onload = (function (theFile) {
return function (e) {
var buffer = e.target.result;
var tiff = new Tiff({buffer: buffer});
var canvas = tiff.toCanvas();
var width = tiff.width();
var height = tiff.height();
if (canvas) {
$('#output').empty().append(canvas);
}
};
})(file);
reader.readAsArrayBuffer(file);
}
$('#file').on('change', function (event) {
show(event.target.files[0]);
});
});</script>
that's what the script I used.
You could install tiff.js as a npm library npm i tiff https://www.npmjs.com/package/tiff
And then import tiff to the App.vue for example, other codes go to mounted(){}.
Instead of Jquery, you could use event on vue template directly, or use javascript to query the element. Using Jquery with Vue is redundant Ithink