Vue single-file component Vue
Đoạn mã Vue cho Vue single-file component, trả lời các yêu cầu tới /pixel.gif bằng GIF rỗng, được giải mã một lần khi khởi động.
Vue single-file component Vue
<script setup>
const EMPTY_GIF = 'data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==';
defineProps({
width: { type: Number, default: 1 },
height: { type: Number, default: 1 },
});
</script>
<template>
<img :src="EMPTY_GIF" :width="width" :height="height" alt="" aria-hidden="true">
</template>
Chúng tôi đã chạy đoạn mã này và so sánh các byte nó trả về.