Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

show two components in vuejs, but only one got displayed, why?

Tags:

vue.js

vuejs newbie got a question, I created two components, 'hello' and 'world', when display then two in the html, only one got displayed, why? Thanks,

https://jsfiddle.net/aaoehLqe/3/

<div id="app">
    <hello :msg="'test1'" /> 
    <world :msg="'test2'" />     
</div>
like image 309
AngeloC Avatar asked Mar 12 '17 15:03

AngeloC


People also ask

How do you emit data from one component to another in Vue?

Using Props To Share Data From Parent To Child # VueJS props are the simplest way to share data between components. Props are custom attributes that we can give to a component. Then, in our template, we can give those attributes values and — BAM — we're passing data from a parent to a child component!

How do I switch between Vue components?

Each component can be linked by using props to pass the methods which will switch the components on triggering a certain event. Here is an example: HTML. CSS.

Can you have multiple Vue instances?

It is totally legal and fine to have multiple Vue instances on your page controlling different parts and pieces of it. In fact, you can even have your instances communicate with each other by storing them in variables within the global namespace.


1 Answers

Self closing tags are not a valid syntax. Try

<hello :msg="'test1'></hello>
<world :msg="'test2'></world>
like image 52
Bert Avatar answered Oct 26 '22 23:10

Bert