【发布时间】:2020-12-06 07:34:13
【问题描述】:
我有一个<input> 和两个<button>s。如果我单击Add new input,则会显示<input>。但是,我想在单击Create 按钮后禁用<input>。 <input> 已经在工作,但在单击 Create 按钮后它不会被禁用。
App.vue
<template>
<div id="app">
<button class="button is-orange has-text-white" @click="addRow">Add Input</button>
<table>
<thead>
<tr>
<th></th>
</tr>
</thead>
<tbody>
<tr v-for="(input, index) in inputs">
<td width="1%">{{++index}}</td>
<td width="18%">
<b-field>
<input v-model="input.one" id="one" class="input one" type="text" placeholder>
</b-field>
</td>
<td width="15%">
<button class="button is-orange has-text-white" @click="inserts(inputs)">Create</button>
</td>
</tr>
</tbody>
</table>
</div>
</template>
<script>
export default {
name: "App",
components: {},
data() {
return {
searchorderid: null,
inputs: [],
data: {},
loading: false
};
},
methods: {
addRow() {
this.inputs.push({
one: ""
});
},
deleteRow(index) {
this.inputs.splice(index, 1);
}
}
};
</script>
<style>
#app {
font-family: "Avenir", Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
}
</style>
我希望输出如下所示:
Create被点击后,前面的<input>应该被禁用。
【问题讨论】:
标签: javascript arrays vue.js vuejs2