PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, July 29, 2022

[FIXED] Why Vue.js image component is doesn't work?

 July 29, 2022     image, javascript, vue-component, vue.js     No comments   

Issue

I have something problem. I wanna make a Vue.js Component. this component show something image. it similar <img>tag.If you know <img>tag, You can understand very easy to this question.

So I want make Vue component like this. my code is following below

  props: ['link,des'],
template: '<img :src={{ link }} :alt={{ des }}></img>'
}),

this code is javascipt

html code is following below

  <image link="https://kr.vuejs.org/images/logo.png" des="sans"></image>

pls answer me kindly. Thank you


Solution

First of all, you can't use the reserved keyword (image) as a component. Then you don't need to use curly brackets for the HTML attributes. Here is the working example.

Vue.component('my-image', {
  props: ['link', 'des'],
  template: `<img :src='link' :alt='des'></img>`
});

new Vue({
  el: '#app'
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>


<my-image id='app' link="https://kr.vuejs.org/images/logo.png" des="sans"></my-image>



Answered By - tuhin47
Answer Checked By - Mildred Charles (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing