Vuejs Input Binding Based on Computed Property
Date : March 29 2020, 07:55 AM
Hope this helps You can make use of a computed setter as follows: computed: {
lastName: {
get(){
//perform your logic
return 'value.second'
},
set(newValue){
this.value.second = newValue;
}
}
}
<input type="text" v-model="lastName" placeholder="Enter last name" />
|
VueJS Input Binding with Nested Data
Date : March 29 2020, 07:55 AM
it should still fix some issue Since your fields.three is an object and not a scalar value, you can not bind it to your input. One thing you can do is to create a function that checks if fields.one, fields.two and fields.three are each simple objects or have nested object. You can use this function: det (param) {
let strlen = param.length
if(1 === strlen){
return param
}
let split = param.split('.')
let details = JSON.parse(JSON.stringify(this.details))
for (var key in details) {
if(key == split[0]){
for (var key2 in details[key]) {
return details[key][key2]
}
}
}
}
|
vuejs b-form-input not binding value
Date : March 29 2020, 07:55 AM
seems to work fine You can't use v-model and value at the same time. V-model is a combination of value and @input. If you use value you must use @change or @input to change the value and delete the v-model. OR, only use v-model.
|
Vuejs Dynamic input binding & computed is not a function
Date : March 29 2020, 07:55 AM
This might help you You need to use Vue.set instead of index [] for object updates to be reactive. Instead of: this.form[`comp_${c}`] = parseFloat(a) / parseFloat(b);
Vue.set(this.form, `comp_${c}`, parseFloat(a) / parseFloat(b));
|
Binding two or more data to a form input in VueJs
Date : March 29 2020, 07:55 AM
With these it helps I was considering having more than one value in a vue form input binding <template>
<div>
<label for=""> Employee </label>
<input class="form-control-plaintext" :value="showAssignedUser()" type= "text" readonly name="surname">
</div>
</template>
<script>
data(){
return:{
asset:{},
}
},
methods:{
getAsset(){
axios.get('/api/assets/'+this.id)
.then ( response => {
this.asset = response.data.data[0].data;
this.toFill = this.asset()
this.assetForm.fill(this.toFill)
})
},
showAssignedUser(){
return `${this.asset.current_status.user.surname}` + ' '+ `${this.asset.current_status.user.first_name}`
},
},
mounted(){
this.getAsset();
}
</script>
|