2

I create component dynamically:

<component is="tab"/>

How to add props for this component? I try:

<component is="tab" my-props="test" />

And I got error in console:

[Vue warn]: Attribute "type" is ignored on component <component> because the component is a fragment instance: http://vuejs.org/guide/components.html#Fragment-Instance

P.S. I'm using 1.0.26 version vue.js.

3
  • What does your tab component look like? The problem might not necessarily be related to the prop you are passing. Commented Aug 31, 2016 at 15:13
  • The problem might be with the attribute/variables found in your component. Post the codes! Commented Aug 31, 2016 at 16:08
  • It is not variable, it is simple text. Without 'my-props' attribute I dont have this warning. Commented Aug 31, 2016 at 20:22

1 Answer 1

4

If test not just "test" text, but some value in your data. Then you need to pass it like so:

<component is="tab" :props="test" />

And don't forget to add your properties in props array inside component. props: ['props'].

http://jsbin.com/zekiyeroka/edit?html,css,js,console,output

Here is working example. Adding to the data is optional, but i prefer this way. Because you can operate your data in the much easier way in the future.

P.S. you need to declare your data in the component like a function, not just object

Sign up to request clarification or add additional context in comments.

3 Comments

It is not working example, it is just jquery code which not relevant for this question.
@Slava fixed. Check it now
Yes, I see. Thank you!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.