Answer the question
In order to leave comments, you need to log in
How to pass variable to vue.js component?
I have a working code
<template>
<div class="row no-margin catalog-content-wrap">
<div class="col-md-4 col-sm-4 col-xs-6 mob-product" v-for="product in $parent.products">
<div class="product" data-product-id="product.id" onmouseenter="$(this).addClass('active')" onmouseleave="$(this).removeClass('active')" >
<div class="product-link text-center">
<div class="img-wrap">
<a :href=" '/product/' + product.slug">
<img class="img-responsive" :src="Website.origin + '/uploads/thumbs/' + product.picture.name" />
</a>
</div>
<a class="product_name" :href=" '/product/' + product.slug" :data-title="product.title">{{product.title }}</a>
<div class="price" v-if="product.price > 0 && product.stock == 1">
<span>{{product.price}}</span> {{$parent.currency}}
</div>
<div class="product-other-info">
<a class="buy" v-if="product.price > 0 && product.stock == 1" href="javascript:void(0);" onclick="Cart.add(this)" :data-product-id="product.id"><i class="fa fa-shopping-basket" aria-hidden="true"></i> {{$parent.loc.buy}}</a>
</div>
</div>
</div>
</div>
</div>
</template>
<template>
<div class="row no-margin catalog-content-wrap">
<product v-for="product in $parent.products" ></product>
</div>
</template>
Answer the question
In order to leave comments, you need to log in
You only create a list of product elements, and you also need to pass the necessary variable to the element itself:
<product v-for="product in $parent.products" :product="product"></product>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question