radeveloper
radeveloper

Reputation: 946

How to set an image path in src attribute using vue 2

İs that possible to give an attribute like that?

src="${urlPath}/img/icon-{{flight.OperatingAirline._CompanyShortName}}.png"

doesn't works.

Upvotes: 3

Views: 1500

Answers (2)

Happyriri
Happyriri

Reputation: 4443

Use :v-bind (or shortcut ":") instead of "{{ }}" : v-bind

So :src="Any javascript here !"

:src="urlPath + '/img/icon-' + flight.OperatingAirline._CompanyShortName + '.png'"

urlPath and flight.OperatingAirline._CompanyShortName must be a javascript variable.

Upvotes: 4

radeveloper
radeveloper

Reputation: 946

After edit @SLYcee's answer for JSTL combined solution:

:src="'${urlPath}/img/icon-' + flight.OperatingAirline._CompanyShortName + '.png'"

Upvotes: 1

Related Questions