Open LingoLasse opened 9 years ago
It's mentioned in the doc: http://vuejs.org/guide/components.html#Using_Components (scroll down to see the warning section)
Use <tr v-component="userrow">
.
It took me a whole afternoon ...
I'm having the same issue using Vue 1.0. I'm doing something like this:
<tbody>
<tr-item v-for="item in items"></tr-item>
</tbody>
There is no parent component.
@aguegu What do you do to solve this?
Well, nevermind: http://vuejs.org/guide/components.html#is_attribute :smile:
Seems that the proposed fix from last year does not work in 1.0. Is there a workaround for the current version?
You would use the is
attribute, as mentioned towards the end of this bit http://vuejs.org/guide/components.html#Template-Parsing
i.e. <tr is="my-component"></tr>
Anyone knows a way to make work v-for inside a vue component? I try a lot of things create use a component inside another component using is="" but not work.
`... template:
Name | \Secund Name | \
---|---|
please how can i use this "is" attribute, i want my custom component to have template like so
<news-items inline-template>
<tr class="gradeX" >
<td><input type="checkbox" /></td>
<td>title</td>
<td>description</td>
</tr>
</news-items>
but i keep getting errors that it must contain only one root element
I've got same problem ! @mazeeblanke Did you find a solution for this ?
<tbody>
<tr is="data-row" v-for="item in items"></tr>
</tbody>
and error:
Component template should contain exactly one root element. If you are using v-if on multiple elements, use v-else-if to chain them instead.
It took me a while to find the correct use of is
. So I share it here:
<table>
<tbody>
<tr is="itemtpl" v-for="item in items" :item="item"></tr>
</tbody>
</table>
[...]
<script type="text/x-template" id="itemtpl-template">
<tr>
<td>{{ item.id }}</td>
<td>{{ item.name }}</td>
</tr>
</script>
I was using Vue.Draggable and the official example for table
didn't work. It was like:
<draggable v-model="list" :element="'tbody'">
It didn't work properly. I had to change it to:
<tbody v-model="list" is="draggable" :element="'tbody'">
It works properly now.
@Aymkdn solution worked for me. without tr in template, it gives no error; but prints only the first data item, instead of looping. Thanks,
This is the documentation you need to read: https://vuejs.org/v2/guide/components.html#Using-Components
Try:
<tr is="vue-table-row"
v-for="(row, index) in rows"
v-bind:row="row"
v-bind:index="index"
v-bind:key="row.id"
></tr>
I'm trying to create a component for a table row. I'm using vue-resource to fetch data from an API created in Laravel.
My problem is that the table rows are rendered above the table and not in the tbody as expected. If I change the table into an unordered list it works just fine. Any ideas?
Here's my code:
HTML
JS
Result