Cómo pasar un valor de datos Vue a href?
Estoy tratando de hacer algo como esto:
<div v-for="r in rentals">
<a bind-href="'/job/'r.id"> {{ r.job_title }} </a>
</div>
No puedo averiguar cómo agregar el valor de r.id
al final del atributo href
para poder hacer una llamada a la API. Alguna sugerencia?
52
3 answers
Necesitas usar v-bind:
o su alias :
. Por ejemplo,
<a v-bind:href="'/job/'+ r.id">
O
<a :href="'/job/' + r.id">
136
Author: asemahle,
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
2016-12-01 02:04:30
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
2016-12-01 02:04:30
O puedes hacerlo con ES6 plantilla literal:
<a :href="`/job/${r.id}`"
18
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 06:01:46
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 06:01:46
Si desea mostrar enlaces procedentes de su estado o tienda en Vue 2.0, puede hacer esto de la siguiente manera:
<a v-bind:href="''">
{{ url_link }}
</a>
1
Author: Waqar Shahid,
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
2018-04-23 11:29:06
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
2018-04-23 11:29:06