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.

dynamic component is vs :is

See original GitHub issue

I was trying to implement dynamic component as explained here: http://vuejs.org/guide/components.html#Dynamic-Components

Not sure if it’s a problem with the documentation or a bug but the example in the documentation does not work, had to remove the colon in front of :is to get it working

Vue.js version

1.0.26 (developement)

What is Expected?

Using <component :is="..."> didnt work as the documentation explains

What is actually happening?

<component is="..."> (is instead of :is) worked

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:21 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
LinusBorgcommented, Aug 16, 2016

@mikekidder I don’t think that it makes sense to explain this for the is attribute specifically - it works just like any other prop in Vue.

We have documented how to use props as well as common pitfalls throughout the documentation, e.g. here: http://vuejs.org/guide/components.html#Literal-vs-Dynamic

1reaction
LinusBorgcommented, Aug 16, 2016

Ok I see, but is without colon is not explained in the doc, I think it should because it’s the behavior I was looking for

To be fair, the general behaviour of props with a leading colon is explained in the docs, in the chapter about Data Binding Syntax and their shortcuts: http://vuejs.org/guide/syntax.html#v-bind-Shorthand

But I can see how that is not obvious to someone scanning the docs for a specific topic.

I therefore think we should try and change docs to use the longhand version for all bindings (v-bind:prop-name="expression").

So the example would then look like this:

<component v-bind:is="currentView">
  <!-- component changes when vm.currentview changes! -->
</component>

Which would tell someone new to Vue that he/she has to look up v-bind in order to fully get what is going on.

Read more comments on GitHub >

github_iconTop Results From Across the Web

An Overview of Vue Dynamic Components - LearnVue
Dynamic components are, well, ways to dynamically switch between components at run-time. While this is a circular definition, ...
Read more >
Dynamic & Async Components - Vue.js
Recreating dynamic components is normally useful behavior, but in this case, ... using the name option on a component, or through local/global registration....
Read more >
2 Simple Examples to understand how Dynamic components ...
ComponentFactory is the base class for a factory that can create a component dynamically. ComponentFactoryResolver maps the Components to the ComponentFactory ...
Read more >
vue.js: what's the difference between <component :is="comp ...
When using dynamic component in vue, we could use component or html tag such as div as the tag name: <component :is="comp-name"></component>.
Read more >
Dynamic Components with Vue's 'component' - Telerik
Another common scenario is having an API endpoint telling you what sort of components it wants the frontend to render on the screen—a...
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