question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Vue: Show code block doesn't render template

See original GitHub issue

I am using Storybook for Vue v6.2.9

I have one component named BaseIcon. It has two props: icon and iconColor.

Why clicking the Show code button doesn’t show the actual template, only raw code from Template?

Screenshot 2021-05-08 at 04 09 51

I wanna it should be like:

<BaseIcon icon="camera" iconColor="white" />

My BaseIcon/index.stories.js code:

import BaseIcon from './index.vue';
import validIcons from './validIconsList';

export default {
  title: 'Components/BaseIcon',
  component: BaseIcon,
  argTypes: {
    icon: {
      options: validIcons,
      control: {
        type: 'select'
      }
    }
  },
 /*  parameters: {
    docs: {
      source: {
        type: 'code'
      }
    }
  } */ 
};

const Template = (args, { argTypes }) => ({
  components: { BaseIcon },
  props: Object.keys(argTypes),
  template: `<BaseIcon v-bind="$props" />`
});

export const Default = Template.bind({});
Default.args = {
  icon: 'camera'
};

Toggling commented parameters property in export default {} does nothing.

What did I miss?

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
prinztcommented, Aug 10, 2021

We experience this behavior for all of our stories too, after upgrading from 6.1.x to 6.3.7. We use Vue 2.6.11.

1reaction
standbyoneselfcommented, May 10, 2021

Do you have a repro repo you can share?

I just created it. Link: https://github.com/standbyoneself/storybook. It is a monorepo. I also created new Lerna package named storybook. It is super default vue project created by vue-cli that has storybook. You need to type yarn storybook and you’ll see that default component`s code also doesn’t look as I want

Screenshot 2021-05-08 at 19 51 35
Read more comments on GitHub >

github_iconTop Results From Across the Web

Vue component within code block, Vue attempting to render ...
i'm trying to display example Vue component's within my documentation, however Vue is also recognizing the template within my Vue component.
Read more >
Docs source loader doesn't render Vue code correctly. #10163
I have been trying to show code snippets of my Vue components in docs, but due to the limitations of vue in docs,...
Read more >
Conditional Rendering - Vue.js
The directive v-if is used to conditionally render a block. The block will only be rendered if the directive's expression returns a truthy...
Read more >
Vue conditional rendering: editing existing todos
We are nearing the end of our Vue series now. ... JavaScript objects that manage the app's data and an HTML-based template syntax...
Read more >
Vue.js | IntelliJ IDEA Documentation - JetBrains
In the Settings/Preferences dialog ( Ctrl+Alt+S ), go to Editor | Code Style | Vue Template, and open the Tabs and Indents tab....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found