Javascript vue js向组件传递数据
您好,我在将数据传递到组件“modal”时遇到问题,我使用带引导vue组件的modal,我需要传递索引,下面是我尝试执行的操作Javascript vue js向组件传递数据,javascript,twitter-bootstrap,vue.js,Javascript,Twitter Bootstrap,Vue.js,您好,我在将数据传递到组件“modal”时遇到问题,我使用带引导vue组件的modal,我需要传递索引,下面是我尝试执行的操作 <table class="table table-striped" v-show="Questions.length!=0"> <tr v-for="Question in Questions"> <td>{{$index + 1}}</td> <td>{{ Question.text }}</
<table class="table table-striped" v-show="Questions.length!=0">
<tr v-for="Question in Questions">
<td>{{$index + 1}}</td>
<td>{{ Question.text }}</td>
<td>
<button v-on:click="showmodal = true" class="btn btn-default" >Manage</button>
<modal :show.sync="showmodal" width="400">
<div slot="modal-header" class="modal-header">
<h4 class="modal-title">Manage Question</h4>
</div>
<div slot="modal-body" class="modal-body">
<div class="input-group col-lg-6">
<input type="text" class="form-control" value="{{ Questions[$index].text }}"></input>
<span class="input-group-btn"><button v-on:click="AddQuestion" class="btn btn-default">Save Question</button></span>
</div>
</div>
<div slot="modal-footer" class="modal-footer">
<button type="button" class="btn btn-default" v-on:click='showmodal = false'>Exit</button>
<button type="button" class="btn btn-success" v-on:click='showmodal = false'>Custom Save</button>
</div>
</modal>
<button class="btn btn-danger" v-on:click="DeleteQuestion($index)">Delete</button>
</td>
</tr>
{{$index+1}}
{{Question.text}
管理
管理问题
保留问题
出口
自定义保存
删去
提示:在索引中传递给模态的数据是最后一个索引,即使模态在循环中使用Vue道具:
在您的示例中:
<modal :show.sync="showmodal" :index="$index" width="400">
...
</modal>
然后,您将能够访问组件内部的索引
,就像任何其他属性一样:此。索引
使用Vue道具:
在您的示例中:
<modal :show.sync="showmodal" :index="$index" width="400">
...
</modal>
然后,您将能够访问组件内部的索引
,就像任何其他属性一样:this.index