请告诉我。我有两个组成部分。“AddFactorComponent.vue”用于将输入的值发送到“数据库”,还有一个内置组件“Factors_lists.vue”,它作为下拉列表。问题是如何将所选值从“Factors_lists.vue”发送到数据库。
AddFactorComponent.vue
<template>
<div class="col-10">
<div class="container-lg d-flex justify-content-center pt-1">
<section class="data-tab" style="border: 1px solid white; width: 1200px">
<div class="d-grid gap-2 d-md-flex justify-content-md-end">
<a href="/"><button type="button" class="btn-close btn-close-white" aria-label="Close"></button></a>
</div>
<div class="mb-3">
<label for="factory_number" class="form-label">Factor evaluated by SI</label>
<el-input v-model="factor" autosize type="textarea" placeholder=""/>
</div>
<div class="d-grid gap-2" >
<label for="factory_number" class="form-label"Factor evaluated by SI</label>
<Factors_lists ></Factors_lists>
</div>
<div class="mb-3">
<label for="factory_number" class="form-label">Equipment ID</label>
<el-input v-model="equipment_id " autosize type="textarea"
placeholder=""/>
</div>
<div class="d-grid gap-2">
<input @click.prevent="Add" class="btn third" value="Add">
</div>
<SpisokFactorComponent ref="spisok_factor_component"></SpisokFactorComponent>
</section>
</div>
</div>
</template>
Factors_lists.vue
<template>
<select v-model="selectedfactors_list">Select your option
<option v-for="factors_list in factors_lists" :key="factors_list.id" :value="factors_list.id">
{{ factors_list.name }}
</option>
</select>
</template>
<script>
export default {
name: "Factors_lists",
data() {
return {
factors_lists: [],
selectedfactors_list: null
}
},
mounted() {
this.getPoluhenie();
},
methods: {
getPoluhenie() {
axios.get('/api/lists')
.then(response => {
this.factors_lists = response.data;
})
.catch(error => {
console.error(error);
});
}
}
}
</script>
控制器
class Factors_listsController extends Controller
{
public function index() {
$items = Factors_lists::all();
return response()->json($items);
}
}
1条答案
按热度按时间93ze6v8z1#
AddFactorComponent.vue
Factors_lists.vue
Factors_listsController
routes/api.php
您需要阅读文档: