gpt4 book ai didi

laravel-5 - 使用 laravel 和 vue 实现前端的最佳实践

转载 作者:搜寻专家 更新时间:2023-10-30 22:44:46 25 4
gpt4 key购买 nike

<分区>

我正在基于 Laravel 5.4 开发一个大型应用程序。我想知道为大规模应用程序实现前端的最佳做法是什么?在 laravel blade 上实现所有样式和 html 渲染并使用 vue 进行交互或使用 blade 调用 vue 组件并实现所有东西是 vue?让我们看一些例子:

这是第一种方法:

在 laravel Blade 中:

@extends('layout')
@section('content')
<customer-search></customer-search>
<customer-table></customer-table>
@endsection

那么客户搜索组件将是:

<template>
<div>
<form action="/customer" method="GET">
<input type="text" name="name" @input="updateValue($event.target.value)" :value="name" />
<submit @click="search">Search</button>
</form>
</div>
</template>
<script>
export default {
data: function () {
return {
name: '',
}
},
methods: {
search() {
// Get data from server, update related data model for using in customer table, ...
}
}
}
</script>

和客户表组件:

<template>
<div>
<table>
<thead>
<tr>
<th>Name</th>
<th>Access</th>
</tr>
</thead>
<tbody>
<tr v-for="customer in customers">
<td>{{ customer.name }}</td>
<td><a href="#">Link</a></td>
</tr>
</tbody>
</table>
</div>
</template>
<script>
export default {

}
</script>

第二种方法: Blade :

@extends('layout')
@section('content')
<customer-index>
<form action="/customer" method="GET">
<input type="text" name="name" @input="updateValue($event.target.value)" :value="name" />
<submit @click="search">Search</button>
</form>

<table>
<thead>
<tr>
<th>Name</th>
<th>Access</th>
</tr>
</thead>
<tbody>
<tr v-for="customer in customers">
<td>{{ customer.name }}</td>
<td><a href="#">Link</a></td>
</tr>
</tbody>
</table>
</customer-index>
@endsection

和客户索引组件:

<tempalte>
<div>
<slot></slot>
</div>
</template>
<script>
export default {
data: function () {
return {
name: '',
}
},
methods: {
search() {
// Get data from server, update related data model for using in customer table, ...
},
// Other methods, ...
}
}
</script>

第三种可能性:第三种可能性是尝试使用第二种方法并更深入地研究组件。例如,使用表格组件、表单组件、输入组件、按钮组件……我应该使用哪一个来渴望在前端花费大量时间并拥有集成的前端?

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com