【发布时间】:2020-04-20 05:03:42
【问题描述】:
在这里,我在组件内正确呈现数据。但是每当我更改需要绑定的数组中未更新的任何输入值时。我无法使用rows 数组对值进行双向绑定。请帮忙。提前致谢。
Vue.component('refund-table', {
template: `
<div>
<div class="table-responsive">
<table class="table table-bordered table-hover table-striped">
<thead>
<tr>
<th v-for="column in columns"> {{column}}</th>
</tr>
</thead>
<tbody>
<tr v-for="(row,index) in rows">
<td >#{{index+1}}</td>
<td v-for="(item,ind) in row">
<input v-if="ind>0" :value="item">
<div v-else>{{item}}</div>
</td>
</tr>
</tbody>
<tfoot>
<tr>
<td></td><td></td><td style="text-align: right">Total</td><td>{{totalRefund}}</td>
</tr>
</tfoot>
</table>
</div>
</div>
`,
props: {
columns: Array,
rows: Array,
caption: String,
edit: Boolean,
},
data() {
return {}
},
mounted() {},
methods: {},
computed: {
totalRefund: function() {
return 100;
}
}
})
new Vue({
el: "#app",
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<refund-table id="app" :columns='["#Serial","a","b","c"]' :rows="[[1,2,3],[1,2,3],[1,2,3],[1,2,3]]" :footer='["a","b","c"]'></refund-table>
【问题讨论】:
-
你是如何测试它没有更新
rows数组的?您应该在帖子中提及所有详细信息。 -
假设您将任何输入值 3 更改为 5,然后在 vue devtools 中您需要在该数组中看到 5 而不是 3。我将该行中的输入绑定
<input v-if="ind>0" :value="item">
标签: vue.js vue-component 2-way-object-databinding