Pil*_*lle 1 javascript css components html-table vue.js
在Vue.js文档中,他们说在使用表中的组件时必须使用v-component而不是direct component-tag.但这不起作用:你有任何解决方法 - 即使使用CSS格式化 - 或修复?
@extends('app')
@section('content')
<div class="table-responsive" id="vueTable">
<table class="table-striped">
<thead>
<td class="table-cell"><strong>Aktion</strong></td>
</thead>
<tr v-component="members" class="success" v-repeat="members" inline-template>
<td>@{{ $data | json }}</td>
</tr>
</table>
</div>
@endsection
@section('footer')
<script src="/js/vue.js"></script>
<script>
var v = new Vue({
el: '#vueTable',
data: {
members: [{
prename: 'Deniz',
lastname: 'Adanc'
}]
},
components: {
members: {
template: ''
}
}
});
</script>
@endsection
Run Code Online (Sandbox Code Playgroud)
埃文再次突破1.0的变化.经过多次尝试失败后,这是html/javascript的组合,当我尝试在表中包含自定义组件(后者又是另一个父组件)时,它对我有用:
HTML文件:
<script id="comments-template" type="text/x-template">
<table>
<tbody>
<tr is="my-comment" :data="comment" v-for="comment in comments">
</tr>
</tbody>
</table>
</script>
<script id="comment-template" type="text/x-template">
<tr>
<td>{{comment}}</td>
</tr>
</script>
Run Code Online (Sandbox Code Playgroud)
JavaScript代码段:
Vue.component('my-comment', {
template: '#comment-template',
props: [
'data',
],
data: function() {
return {
comment: '',
};
},
ready: function() {
this.comment = this.data.comment;
}
...
});
Vue.component('my-comments', {
template: '#comments-template'
...
});
Run Code Online (Sandbox Code Playgroud)
这里有两个组件:( my-comments这是一个表)和my-comment(表中的行/行).commentfrom v-for循环作为data属性传递,并在内部重新映射my-comment到my-comment(this.comment = this.data.comment)的实际数据.
它看起来相当丑陋,并不完全直观,但至少它是有效的.