1👍
bind the input type to variable and change that variable
<template>
<div>
<input :type="inputType" />
<button @click="changeType />
</div>
</template>
<script>
export default {
data() {
return {
inputType: "text",
}
},
methods: {
changeType() {
if (this.inputType === "text") {
this.inputType = "radio"
} else {
this.inputType = "text"
}
}
}
}
</script>
- [Vuejs]-Why can I not push data to new object after filtering it with forEach?
- [Vuejs]-Vue.js 2.6 use :to="leading to a component " and :href="leading to a web page" at the same time, is it possible?
1👍
Here is the solution of your answer, By clicking on button all input types will be changed from radio to checkbox.
<div id="test">
<div class="input-group mb-3" v-for="(input, k) in inputs" :key="k">
<input :type="input" class="abc" disabled>
</div>
<div class="btn btn-sm" @click="changeInputType">Change Input Type</div>
</div>
<script>
var app = new Vue({
el: "#test",
data() {
return {
inputs: ['radio', 'radio']
}
},
methods: {
changeInputType() {
this.inputs = ['checkbox', 'checkbox']
},
}
});
</script>
1👍
On butt click change the type variable to checkbox.
<script>
var app = new Vue({
el: "#test",
data() {
return {
input: 'radio'
}
},
methods: {
btnClick() {
this.input = 'checkbox'
},
}
});
</script>
- [Vuejs]-How to Install Vuetify in a Laravel 9 Project
- [Vuejs]-Petite-Vue on-click missing in compiled html, and "not defined" for reactive properties in app
Source:stackexchange.com