cart.blade.php
<shopping-cart :cart_data="{{ json_encode($cart_data) }}"></shopping-cart>
components Vue
ShoppingCart.vue
<template>
<div>
<div class="row">
<div class="col-lg-8">
<div class="page-content" v-for="product in cart_data['product']">
<ul class="cart-table">
<li>
<div class="row">
<div class="col-md-2">
<a href="">
<img v-bind:src="$siteUrl+'/files/thumbnails/'+product.product_img_url" alt="">
</a>
</div>
<div class="col-md-10">
<a href="" class="product-title">{{ product.product-title}}</a>
</div>
</div>
</li>
</ul>
</div>
</div>
</div>
</template>
داخل مرور گر نه product_title نه product_img_url نشون نمیده
<script>
import myMixin from "../myMixin";
export default {
name: "ShoppingCart",
props: ['cart_data'],
mixins: ['myMixin'],
data () {
return {
}
},
mounted() {
alert(this.cart_data['product'][0]['product_title']);
},
methods: {
}
}
</script>
داخل فایل app.js
/ === Shopping Cart === /
import ShoppingCart from "./components/ShoppingCart";
const app = new Vue({
el: '#app',
components : {
ShoppingCart
}
});
خطلای زیر نشون میده
[Vue warn]: Error in mounted hook: "TypeError: this.cart_data.product is undefined"
found in
---> <ShoppingCart> at resources/js/components/ShoppingCart.vue
<Root> ShopVue.js:4135:15
VueJS 24
سلام
من json_encode به صورت زیر وارد کردم
<shopping-cart :cart_data="{!! json_encode($cart_data) !!}"></shopping-cart>
به صورت زیر چاپ کرد و component ShoppingCart اجرا نکرد.
":[{"product_id":6,"product_url":"\u06a9\u0644\u0627\u0647-\u06a9\u0648\u0647\u0646\u0648\u0631\u062f\u06cc-\u062c\u06a9-\u0648\u0644\u0641-\u0627\u0633\u06a9\u06cc\u0646-\u0645\u062f\u0644-9866","product_title":"\u06a9\u0644\u0627\u0647="" \u06a9\u0648\u0647\u0646\u0648\u0631\u062f\u06cc="" \u062c\u06a9="" \u0648\u0644\u0641="" \u0627\u0633\u06a9\u06cc\u0646="" \u0645\u062f\u0644="" 9866","product_img_url":"1612585890.jpg","warranty_name":"\u06af\u0627\u0631\u0627\u0646\u062a\u06cc="" \u0627\u0635\u0627\u0644\u062a="" \u0648="" \u0633\u0644\u0627\u0645\u062a="" \u0641\u06cc\u0632\u06cc\u06a9\u06cc="" \u06a9\u0627\u0644\u0627","warrant_id":1,"color_name":"\u0622\u0628\u06cc="" \u06a9\u0627\u0631\u0628\u0646\u06cc","color_code":"#293542","color_id":16,"price1":"\u06f1\u06f9\u06f0,\u06f0\u06f0\u06f0","price2":"\u06f1\u06f6\u06f5,\u06f0\u06f0\u06f0","product_number_cart":1,"product_count":1},{"product_id":9,"product_url":"\u0686\u0627\u062f\u0631-\u0645\u0633\u0627\u0641\u0631\u062a\u06cc-3-\u0646\u0641\u0631\u0647-\u067e\u06a9\u06cc\u0646\u06cc\u0648-\u0645\u062f\u0644-k-2003","product_title":"\u0686\u0627\u062f\u0631="" \u0645\u0633\u0627\u0641\u0631\u062a\u06cc="" 3="" \u0646\u0641\u0631\u0647="" \u067e\u06a9\u06cc\u0646\u06cc\u0648="" k-2003","product_img_url":"1614196606.jpg","warranty_name":"\u06af\u0627\u0631\u0627\u0646\u062a\u06cc="" \u06a9\u0627\u0644\u0627","warrant_id":1,"color_name":"\u0642\u0631\u0645\u0632","color_code":"#ff0000","color_id":3,"price1":"\u06f2,\u06f7\u06f4\u06f4,\u06f0\u06f0\u06f0","price2":"\u06f2,\u06f5\u06f4\u06f4,\u06f0\u06f0\u06f0","product_number_cart":1,"product_count":1},{"product_id":9,"product_url":"\u0686\u0627\u062f\u0631-\u0645\u0633\u0627\u0641\u0631\u062a\u06cc-3-\u0646\u0641\u0631\u0647-\u067e\u06a9\u06cc\u0646\u06cc\u0648-\u0645\u062f\u0644-k-2003","product_title":"\u0686\u0627\u062f\u0631="" \u06a9\u0627\u0644\u0627","warrant_id":1,"color_name":"\u0632\u0631\u062f="" \u0641\u0633\u0641\u0631\u06cc","color_code":"#b1d61d","color_id":23,"price1":"\u06f2,\u06f8\u06f0\u06f0,\u06f0\u06f0\u06f0","price2":"\u06f2,\u06f8\u06f0\u06f0,\u06f0\u06f0\u06f0","product_number_cart":1,"product_count":1},{"product_id":9,"product_url":"\u0686\u0627\u062f\u0631-\u0645\u0633\u0627\u0641\u0631\u062a\u06cc-3-\u0646\u0641\u0631\u0647-\u067e\u06a9\u06cc\u0646\u06cc\u0648-\u0645\u062f\u0644-k-2003","product_title":"\u0686\u0627\u062f\u0631="" \u06a9\u0627\u0644\u0627","warrant_id":1,"color_name":"\u0646\u0627\u0631\u0646\u062c\u06cc","color_code":"#ffa500","color_id":6,"price1":"\u06f2,\u06f7\u06f4\u06f4,\u06f0\u06f0\u06f0","price2":"\u06f2,\u06f5\u06f4\u06f4,\u06f0\u06f0\u06f0","product_number_cart":1,"product_count":1},{"product_id":4,"product_url":"\u06a9\u06cc\u0633\u0647-\u062e\u0648\u0627\u0628-\u06a9\u0644\u0645\u0646-\u0645\u062f\u0644-palmetto","product_title":"\u06a9\u06cc\u0633\u0647="" \u062e\u0648\u0627\u0628="" \u06a9\u0644\u0645\u0646="" palmetto","product_img_url":"1612511906.jpg","warranty_name":"\u06af\u0627\u0631\u0627\u0646\u062a\u06cc="" \u06a9\u0627\u0644\u0627","warrant_id":1,"color_name":"\u0642\u0631\u0645\u0632","color_code":"#ff0000","color_id":3,"price1":"\u06f4,\u06f6\u06f8\u06f9,\u06f0\u06f0\u06f0","price2":"\u06f4,\u06f6\u06f8\u06f9,\u06f0\u06f0\u06f0","product_number_cart":1,"product_count":1},{"product_id":3,"product_url":"\u06a9\u06cc\u0633\u0647-\u062e\u0648\u0627\u0628-\u0646\u06cc\u0686\u0631\u0647\u0627\u06cc\u06a9-\u0645\u062f\u0644-nh01-down-dk800l","product_title":"\u06a9\u06cc\u0633\u0647="" \u0646\u06cc\u0686\u0631\u0647\u0627\u06cc\u06a9="" nh01="" down="" dk800l","product_img_url":"1612511599.jpg","warranty_name":"\u06af\u0627\u0631\u0627\u0646\u062a\u06cc="" \u06a9\u0627\u0644\u0627","warrant_id":1,"color_name":"\u0645\u0634\u06a9\u06cc","color_code":"#000000","color_id":2,"price1":"\u06f4,\u06f4\u06f0\u06f0,\u06f0\u06f0\u06f0","price2":"\u06f4,\u06f4\u06f0\u06f0,\u06f0\u06f0\u06f0","product_number_cart":1,"product_count":1}],"total_price":"\u06f1\u06f7,\u06f5\u06f6\u06f7,\u06f0\u06f0\u06f0","cart_price":"\u06f1\u06f7,\u06f1\u06f4\u06f2,\u06f0\u06f0\u06f0","discount":"\u06f4\u06f2\u06f5,\u06f0\u06f0\u06f0","product_count":"\u06f6"}"="">
آیا مایل به ارسال نوتیفیکیشن و اخبار از طرف راکت هستید ؟