Vue.js and Onsen UI app displaying broken images

I tried the code below to display an image in my Vue.js and Onsen UI App, but unfortunately the images are not appearing.

  <div class="footer_logo">
    <ul>
      <li class=""><img :src="logo" alt="logo" /></li>
    </ul>
  </div>

The code I used to import the image in the script is shown below:

import foot1 from 'static/assets/img/footerlogos/1.svg';
export default {
  data() {
      logo: foot1;
  }

Edit

Here is a snapshot of the project structure:

https://i.sstatic.net/pTKXu.png

Answer №1

SVG files can sometimes cause issues, so make sure to change them and then test if they are working properly. If not, follow the suggested solution below.

To resolve this issue, ensure that all your image files are placed in the assets folder inside the src directory, rather than in src/static.

Try the following:

  • Create an 'assets' directory within the 'src' folder (be certain it is named 'assets' and not anything else)
  • Add an image file, for example: logo.jpg

Next, update your code as shown below:

<div class="footer_logo">
    <ul>
      <li class=""><img :src="logo" alt="logo" /></li>
    </ul>
  </div>

Lastly, modify your script by importing the image correctly:

import foot1 from 'assets/logo.jpg';
export default {
  data() {
      logo: foot1;
  }

Answer №2

If your project has a static folder at the root, it's recommended to use a root suffix in this manner:

import foot1 from '@static/assets/img/footerlogos/1.svg';

export default {
  data() {
      logo: foot1;
}

For more information, check out these references:

Answer №3

Incorporate a relative pathway in this manner:

import foot1 from '../static/assets/img/footerlogos/1.svg';

export default {
  info() {
      graphic: foot1;
}

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

React.js - Add a new row div when reaching a limit of X items to keep the layout

Currently in the process of learning React.js. Here is the code snippet I am working with: const items = Object .keys(this.state.items) .map(key => <Item key={key} details={this.state.items[key]} />) ; return ( <div className ...

How do I use jQuery to remove a dynamically added class from the page's header?

When using an inline editor to modify css classes, I encounter the need to remove and then re-add a class definition after making changes. Additionally, users have the option to delete elements, so it's important that the definition is also deleted. ...

Instructions on passing a PHP variable as a parameter to a JavaScript function when a button is clicked

In my implementation of codeigniter 3, I have a view page where the data from $row->poll_question is fetched from the database. The different values within this variable are displayed on the voting.php page. Next to this display, there is a button label ...

Building an interface with Angular, Node, and Mongoose to display posts, comments, and replies

I have a vision for an interactive Application where users can engage by asking questions, providing answers, and replying to those answers. While I have successfully rendered posts and answers, I am facing challenges in implementing replies to answers. Ca ...

What is the correct method for routing Vue/AJAX requests in Laravel?

I am new to Laravel and creating a web service that can operate without the need for JavaScript, in case it is disabled by the user. However, I believe it would enhance the user experience if certain actions could be performed without having to refresh th ...

Creating a spherical shape without relying on SphereGeometry: Is it possible?

I am attempting to create a sphere without utilizing SphereGeometry. My approach involves drawing the sphere using latitudes and longitudes. Below is the code snippet I am working with: for (var phi = -Math.PI / 2; phi < Math.PI / 2; phi += Math.PI / 1 ...

Personalize the appearance of dynamically generated DIV elements

This script generates a random number of squares (ranging from 20 to 40) and adds text to each square. The script then calculates the width of each square so that they all fit in a single row. Here is the code snippet: var quantity = Math.floor(Math.ran ...

AngularJS + Asynchronous Operations

I'm working with AngularJS and I have two API methods in my factory. I've been trying to call these two methods one after the other, but it's not functioning as expected. The desired sequence is to first execute test1 followed by test2. Be ...

What is the best approach to comply with the EsLint rule "react-hooks/exhaustive-deps" and properly implement componentDidMount using hooks in React with a warning level?

After reviewing the React documentation, it appears that componentDidMount is now implemented using hooks as shown below: useEffect(() => { // your code here }, []) For example, if you wish to make an API call within this hook: useEffect(() => { ...

Set a delay for an AJAX request using jQuery

Is it possible to incorporate a setTimeout function into this ajax call? Here's the code snippet: jQuery.ajax({ type : "POST", url : dir+"all/money/myFile.php", data : "page="+data.replace(/\&/g, '^'), suc ...

Unable to include the 'date' header while making an AJAX request using jQuery

It appears that the issue lies on the client side or browser as we are unable to see in the request headers, ruling out a server problem. $(document).ready(function(e) { $.ajax({ url: form_url, type: form_method, ...

An alternative solution for flatmap in JavaScript

Searching for a workaround for flat map not working on IE led me to this solution, but the reasoning behind it eludes me. var gadjets = [ {computers:['asus', 'hp'], sellphones:['Galaxy', 'Nokia'] }, {comput ...

Obtaining Serialized Data

Using the JavaScript serializer to send data to JavaScript: var jsSerializer = new JavaScriptSerializer(); var result = (from c in dt.AsEnumerable() select new { Latitude = c.F ...

Is there a way to navigate to a link with CasperJS without having to specify the CSS selector?

<a href="pss.exe?TRANSACTION=CGI_JUMP&amp;SESSDATA=randomstuff&amp;SKIN=default&amp;LANG=en-US"> Update your password </a> <a href="psk.exe?TRANSACTION=CGI_JUMP&amp;SESSDATA=randomstuff&amp;SKIN=default&amp;LANG=en ...

Update the pageExtensions setting in Next.js to exclude building pages with the file extension *.dev.*

I am currently working on a project using Next.js version v12.3, and I have encountered an issue related to excluding page files with a *.dev.* extension from the build process. In my configuration file next.config.js, I have configured the pageExtensions ...

In search of javascript implementations of the pubhubsubbub protocol that are open source

Can you list out some of the open-source Javascript implementations for the PubSubHubbub protocol, starting with the publishing side? ...

show various commands and outcomes of the getElementsByClassName() function

Can someone help me figure out how to use the "getElementsByClassName() Method" in JavaScript to change or display different colors? I am trying to change the background color to blue for the class "ex" and red for the class "example", but it's not wo ...

The issue I'm facing is that the ng-click functionality in Angular JS is not functioning properly when the

Upon loading the page, my JavaScript function creates a tree structure from JSON data and generates a list of anchor tags which look like this: <a ng-click="shareParent(4619)">Some data</a> Despite associating the ng-click directive with the ...

Learn how to dynamically enable or disable the add and remove buttons in the PrimeNG PickList using Angular 2

I'm currently learning Angular 2 and I'm working on creating a dual list box using PrimeNG's pickList component (https://www.primefaces.org/primeng/#/picklist). Within the pickList, I have table data with 3 columns, along with ADD and REMO ...

What is the best way to seamlessly incorporate a new line into the string saved in the AMP state?

I am exploring the world of Accelerated Mobile Pages and trying to enhance my skills. My current challenge involves adding a new line and some additional text content to a string stored in the amp-state when the user clicks a button. Here is what I have at ...