Is it possible that the images are unable to load on the page

The frontend code successfully retrieves the image links sent by the backend but encounters issues displaying them. Despite confirming that the imgUrl data is successfully fetched without any hotlink protection problems, the images are still not appearing on the screen. enter image description here Below is the updated code:

<template>
  <div v-if="isLoading" class="loading-message">...</div>
  <div v-else class="card-container">
    <el-backtop :right="100" :bottom="100" />
    <div class="card" v-for="(card, index) in cards" :key="index">
      <div class="add-icon" @click="addToFavorites(card)">
        <el-icon><IEpCirclePlus /></el-icon>
      </div>
      <div class="card-content">
        <div class="left-content">
          <img
              v-if="card.imgUrl"
              :src="card.imgUrl"
              alt="Card Image"
              class="card-image"
              @click="handleButtonClick(card.link, index)"
              @mouseover="card.isRotated = true"
              @mouseout="card.isRotated = false"
              :style="{ transform: card.isRotated ? 'rotate(360deg)' : 'rotate(0deg)' }"
          />
          <div v-else class="loading-message">...</div>
        </div>
        <div class="right-content">
          <h3>{{ card.name }}</h3>
          <div class="divider"></div>
          <p>{{ card.description }}</p>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import axios from "axios";
import { ElMessageBox, ElMessage } from "element-plus";

export default {
  data() {
    return {
      cards: [],
      maxFavorites: 12,
      isLoading: true,
    };
  },
  methods: {
    async fetchDataFromApi() {
      try {
        const response = await axios.get("api/entertainmentTools/loadDataList");
        const responseData = response.data;
        if (responseData.status === "success" && responseData.code === 200) {
          this.cards = responseData.data.map((card) => ({ ...card, isRotated: false }));
          console.log(this.cards)
        } else {
          // 
        }
      } catch (error) {
        // 
      } finally {
        this.isLoading = false;
      }
    },
    handleButtonClick(link, index) {
      window.open(link, "_blank");
      this.cards.forEach((card, i) => {
        card.isRotated = index === i;
      });
    },
    addToFavorites(card) {
      const favorites = JSON.parse(localStorage.getItem("favorites") || "[]");
      if (favorites.length >= this.maxFavorites) {
        ElMessageBox.alert("12", "", {
          confirmButtonText: "",
          callback: () => {
            
          },
        });
      } else {
        
        const favoriteCard = { name: card.name, imgUrl: card.imgUrl, link: card.link };
        favorites.push(favoriteCard);
        localStorage.setItem("favorites", JSON.stringify(favorites));
        ElMessage.success("success");
      }
    },
  },
  async created() {
    
    await this.fetchDataFromApi();
  },
};
</script>

In a revised version of the code realizing potential data retrieval and rendering challenges, modifications were made to address these concerns. However, the issue persists as the images remain invisible on the interface.

Answer №1

The imgUrl in the card does not correspond with the data key imgurl. The "u" is not capitalized.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Add a new module to your project without having to rely on the initial

I'm looking to experiment with a module by making some adjustments for testing purposes. You can find the code here. Currently, all I need to do is type "npm install angular2-grid" in my terminal to add it to my project. Here's my concern: If ...

Displaying iterative content using Vue.js from an array of items

Looking to style questions and answers differently when rendering them. The data structure is as follows: dialogTut:{ mainTab:{ q:"data with 42 people?", a:"hehe", q:"Are awesome people?", a:"sometimes", ...

What are the best strategies for breaking down an AngularJS application into smaller modules and managing routing effectively?

What is the most effective way to divide an AngularJS application into smaller modules? For instance, if I have a blog post with commenting functionality, I could potentially separate them into modules like "posts" and "comments", rather than having all th ...

Get the value of an HTML element

Is there a way to retrieve the value of an HTML element using PHP or JavaScript, especially when the value is dynamically loaded from another source? I have tried using jQuery with the DOM ready event, but often encounter the issue where the element's ...

In my experience, Angular will generate an error if a form tag in HTML contains special characters, such as the colon symbol ':' in the 'name' attribute

Currently, I am in the midst of a Salesforce project and I am contemplating utilizing Angular JS for its remarkable capabilities. One issue I have encountered is that Salesforce prefixes form attributes like name and id with dynamic IDs. For example, if th ...

Resolving label overlapping issue in Chart.js version 2

I am currently utilizing Chart.js 2 for a project of mine. I've successfully customized the style, but there's one persistent issue that I can't seem to resolve and it's becoming quite frustrating. Occasionally, the last label on the x ...

Pages with embedded HTML code

Within the confines of locale/lang.json, there resides { "title": "Title", "image": "service-corporate_thumb-v2.jpg", "alt": "alt", "imageFooter": "Some caption %", "imageFooterCTA": "author", "imageFooterURL": "https://example.com/author", } ...

Showing information in a modal dialog in an Angular 4 application

As an Angular 4 developer, I am working on an application where I need to display data in a dialog. To achieve this, I am using @Output to pass data from the child component to the parent component. In the parent component, my code looks like this: expor ...

What steps are involved in integrating Element Plus with Nuxt 3?

Seeking assistance with installing Element Plus in Nuxt 3. I followed the instructions from the official Element Plus documentation, but despite adding unplugin-vue-components, unplugin-auto-import, and adjusting webpack settings in the nuxt config file, ...

Tips for formatting strings to be compatible with JSON.parse

I'm encountering an issue with my node.js application where I am attempting to parse a string using JSON.parse. Here is the code snippet: try{ skills = JSON.parse(user.skills); }catch(e){ console.log(e); } The string stored in user.skill ...

Unable to deploy Firebase functions following the addition of an NPM package

Scenario: I recently tried integrating Taiko into my Firebase web application, similar to Puppeteer. It's worth mentioning that Taiko downloads Chromium for its operations. Challenge: Ever since then, none of my functions are deploying successfully. ...

The SrollToTop function is ineffective when used with a component in Ionic 6/Angular

Recently, I implemented a fabbutton feature that allows users to scroll to the top of a page with just one click. Initially, I tested this functionality without using it as a component, and everything worked perfectly. However, now I want to turn this fabb ...

Revolutionizing messaging with Vue JS and Firebase

My web application is designed to check if a user has messages in the Firebase database. If messages are found, it retrieves the data from the users who sent those messages from my local database and displays them in a list using a v-for loop. The display ...

The system seems to be having trouble locating the password property, as it is returning a value of

I'm currently working on a database project using MongoDB and Node.js. I'm trying to update a specific field, but unfortunately I keep getting an error. The model I am working with is called "ListaSalas": router.post('/updatesala', fun ...

The behavior of the select menu is erratic when interacting with AJAX

My dropdown menu is populated dynamically based on AJAX response: function populateDropdown(dropdownNum) { // invokeWebService using $.ajax json = invokeWebService("GET", "/webservice/dropwdownOptions"); optionsHtml = ""; $.each(json, function(count, jsO ...

Encountering a 500 internal server error or receiving an error message stating "invalid value for stripe.confirmCardPayment

I'm currently working on implementing a payment component for my React app using Stripe for the first time. Despite following a tutorial closely, I keep encountering an internal server error or receiving an "invalid value for stripe.confirmCardPayment ...

Display a smaller image preview in the product photo gallery

Hey there! I'm currently working on a website and looking to showcase my product in a similar way as shown here: I would like my main image to be displayed with all the other variants of the product image underneath, along with the same visual effect ...

Reasons why the Express Route fails to store cache while executed in a separate file

My code works fine when it's all in one file, but the caching stops working when I move it to a separate middleware file. Can someone help me understand why the caching isn't functioning properly in my middleware? Here is the working code: var e ...

Issue encountered while appending new rows to the tbody of a table

I'm encountering an issue with the append function within a for loop in my code. The string being passed to the function isn't parsing correctly and results in an error. How can I go about resolving this problem? Thanks! function getDetailPopUp ...

Nuxt.js framework and Three.js library are throwing a SyntaxError: Unable to utilize an import statement outside of a module

Utilizing Nuxt.js to develop a static landing page and integrating Three.js for rendering a 3D Globe on the page. It works flawlessly in both dev and production modes locally, but upon deploying to netlify using yarn generate to create a full static site, ...