<div id="app" class="ui segment">
<div data-bullshit-attribute="<?=$model->title;?>" ref="div"></div>
<?php if($model->lastfile->num):?>
<div data-lastnum-attribute="<?=$model->lastfile->num;?>" ref="div2"></div>
<?php else:?>
<div data-lastnum-attribute="0" ref="div2"></div>
<?php endif;?>
<div v-for="(user, index) in users">
<div class="ui grid object_target">
<div class="four wide column field">
<?= $form->field($model4, 'file[]')->fileInput(['multiple' => true, 'accept' => 'image/*']) ?>
</div>
<div class="two wide column field">
<label style="font-weight: normal;font-size: 14px;" >Номер</label>
<input type="text" v-model="user.procent" disabled="disabled" name="dirFiles[num][]" />
</div>
<div class="four wide column field">
<?= $form->field($model4, 'date_dog[]')->textInput(['maxlength' => true,'type'=>'date','disabled'=>$disabled,'value'=>date('Y-m-d',time()) ]);?>
</div>
<div class="three wide column field">
<?= $form->field($model4, 'cat_id[]')->dropDownList($dops,$params_cat_dop);?>
</div>
<div class="one wide column field">
<p @click="deleteUser(index)" class="ui button red" style="margin-top:20px;">
<i class="ui icon trash"></i>
</p>
</div>
</div>
</div>
<p @click="addUser" class="ui button">
+
</p>
</div>
new Vue({
el: '#app',
data: {
users: [{ name: '',procent:'' }],
message:'1',
},
methods: {
addUser(index) {
var vm = this
this.users.push({
name: '',
procent: this.users.length+1,
});
},
deleteUser: function (index) {
console.log(index);
console.log(this.finds);
this.users.splice(index, 1);
if(index===0)
this.addUser()
},
},
computed: {
percentTotal() {
return this.users.reduce((acc, user) => acc + parseInt(user.procent, 10), 0)
},
},
});
Как при инициализации компонента сразу узнать значение data-lastnum-attribute, и положить в input procent?