Guest User

Untitled

a guest
Mar 24th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. <template>
  2. <span :class="'icon ' + this.classes"></span>
  3. </template>
  4.  
  5. <script>
  6. let cache = new Map();
  7.  
  8. export default {
  9. props: {
  10. src: {
  11. type: String,
  12. required: true
  13. },
  14. classes: {
  15. type: String,
  16. default: function() {
  17. return ''
  18. }
  19. },
  20. },
  21. async mounted() {
  22. if (!cache.has(this.src)) {
  23. try {
  24. cache.set(this.src, fetch(this.src).then(r => r.text()));
  25. } catch (e) {
  26. cache.delete(this.src);
  27. }
  28. }
  29. if (cache.has(this.src)) {
  30. this.$el.innerHTML = await cache.get(this.src);
  31. }
  32. }
  33. };
  34. </script>
Add Comment
Please, Sign In to add comment