Vue.js img src concatenar variable y texto
Quiero concatenar la variable Vue con la url de la imagen. ¿A qué me refiero?
Calculado:
imgPreUrl : function(){
if(androidBuild) return "android_asset/www/";
else return "";
}
Si compilo para Android:
<img src="/android_asset/www/img/logo.png">
Else
<img src="img/logo.png">
¿Cómo concatenar la variable calculada con la url? Lo intenté:
<img src="{{imgPreUrl}}img/logo.png" >
Gracias
37
Author: Dan Mindru, 2016-10-26
2 answers
No se pueden usar rizos (etiquetas de bigote) en atributos. Utilice lo siguiente para concat datos:
<img v-bind:src="imgPreUrl + 'img/logo.png'">
O la versión corta:
<img :src="imgPreUrl + 'img/logo.png'">
Lea más sobre los atributos dinámicos en los documentos de Vue .
78
Author: Dan Mindru,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-08-22 19:13:14
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-08-22 19:13:14
En otro caso soy capaz de usar plantilla literal ES6 con backsticks, así que para el tuyo se podría establecer como:
<img v-bind:src="`${imgPreUrl()}img/logo.png`">
13
Author: Ardhi,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-07-13 05:55:50
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-07-13 05:55:50