Storybook: كيفية إضافة المقابض لمكونات VUE في 6.0؟

تم إنشاؤها على ٢٥ نوفمبر ٢٠٢٠  ·  1تعليق  ·  مصدر: storybookjs/storybook

أهلا. ليس لدي أي فكرة ساخنة على الإطلاق لجعل المقابض تعمل بشكل تفاعلي. لم يتم العثور على أي أمثلة على الويب أيضًا.

هذا هو الكود الخاص بي:

import ElBtn from '../components/elements/buttons/el-btn.vue';

export default {
    title: 'El-Btn',
    component: ElBtn,
    decorators: [() => `<section class="container"><story /></section>`],
    argTypes: {
        type: { control: { type: 'select', options: ['secondary', 'primary'] } },
        round: { control: { type: 'boolean', default: false } },
    },
};

export const primary = () => ({
    components: { ElBtn },
    template: `<el-btn>Text</el-btn>`,
});

export const secondary = () => ({
    props: {
        type: { control: { type: 'select', options: ['secondary', 'primary'] } },
    },
    render() {
        return <ElBtn type="this.type">Test</ElBtn>;
    },
});

تمت الإضافة عبر Vue CLI 4.5.0 (إضافة كتاب قصة).

تبعيات dev ذات الصلة:

    "@storybook/addon-essentials": "^6.0.26",
    "@storybook/addon-links": "^6.0.26",
    "@storybook/vue": "^6.0.26",

تظهر كلتا عناصر التحكم في كلتا القصتين ، لكن لم يغير أي منهما العناصر الفعلية.

أيضًا ، سأكون ممتنًا لأي أمثلة من كتاب القصص القصيرة 6.0 مفتوح المصدر مع vue أو أي أدلة ذات صلة.

PN controls vue question / support

التعليق الأكثر فائدة

export const primary = (args, { argTypes }) => ({
    props: Object.keys(argTypes),
    components: { ElBtn },
    // v-bind by itself takes every key in the value and v-binds them to a field on this component
    // $props is every prop on the `primary` component
    template: `<el-btn v-bind="$props">Text</el-btn>`,
});

بالنسبة للثانوية ، يمكنك اتباع هذا التخطيط للدعائم أيضًا.

حد ذاتها هنا لمزيد من المعلومات
https://storybook.js.org/docs/vue/writing-stories/args#story -args

>كل التعليقات

export const primary = (args, { argTypes }) => ({
    props: Object.keys(argTypes),
    components: { ElBtn },
    // v-bind by itself takes every key in the value and v-binds them to a field on this component
    // $props is every prop on the `primary` component
    template: `<el-btn v-bind="$props">Text</el-btn>`,
});

بالنسبة للثانوية ، يمكنك اتباع هذا التخطيط للدعائم أيضًا.

حد ذاتها هنا لمزيد من المعلومات
https://storybook.js.org/docs/vue/writing-stories/args#story -args

هل كانت هذه الصفحة مفيدة؟
0 / 5 - 0 التقييمات