تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
1 الرد
1572 أدوات العرض

Dear all,

I have a JS class as below:

export class Product extends Component {

    static components = { PTAL };

    static template = "sale_product_configurator.product";

    static props = {

        id: { type: [Number, {value: false}], optional: true },

        product_tmpl_id: Number,

        display_name: String,

        description_sale: [Boolean, String], // backend sends 'false' when there is no description

        price: Number,

}

Now I want to inherit and add new items for props, but I do not know how to do.

Help me please.

Thank.

الصورة الرمزية
إهمال
أفضل إجابة

Hi,

To inherit and add new items to the props in your Product component class, you can extend the class and then define the additional props in the new class. Here’s how you can do it:

``` import { Product } from '@sale_product_configurator/js/product/product';


export class ExtendedProduct extends Product {

    static props = {

        ...Product.props,

        new_prop1: String, // Add new properties here

        new_prop2: Number,

    };

}


Hope it helps

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
4
فبراير 25
1375
2
نوفمبر 24
2495
3
أكتوبر 23
14279
2
فبراير 23
2064
1
ديسمبر 22
1371