Storybook: Wie füge ich Regler für Vue-Komponenten in 6.0 hinzu?

Erstellt am 25. Nov. 2020  ·  1Kommentar  ·  Quelle: storybookjs/storybook

Hallo. Ich habe absolut keine Ahnung, wie heiß es ist, Knöpfe reaktiv zu machen. Ich habe auch keine Beispiele im Web gefunden.

Hier ist mein Code:

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>;
    },
});

Hinzugefügt über Vue CLI 4.5.0 (vue add storybook).

Relevante Entwicklungsabhängigkeiten:

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

Beide Steuerelemente in beiden Storys werden angezeigt, aber keines von ihnen ändert die tatsächlichen Requisiten.

Wäre auch dankbar für alle OpenSource Storybook 6.0 Beispiele mit Vue oder relevante Anleitungen.

PN controls vue question / support

Hilfreichster Kommentar

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>`,
});

Für die Sekundarstufe können Sie diesem Layout auch für die Requisiten folgen.

se hier für mehr
https://storybook.js.org/docs/vue/writing-stories/args#story -args

>Alle Kommentare

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>`,
});

Für die Sekundarstufe können Sie diesem Layout auch für die Requisiten folgen.

se hier für mehr
https://storybook.js.org/docs/vue/writing-stories/args#story -args

War diese Seite hilfreich?
0 / 5 - 0 Bewertungen