javascript - laravel Blade 组件和 vue 组件有什么区别?

标签 javascript php laravel vue.js

Laravel 拥有基于 Vue 组件的 Blade 组件,您甚至可以在 Laravel 中使用 Vue 组件。那么他们两者有什么区别呢?当你必须互相使用时,即在这种情况下,你会更喜欢 Laravel Blade 组件而不是 Vue 组件,反之亦然。

最佳答案

基于组件的方法

Component Based Approach

Image credit

Blade 组件

The idea of Blade components and slots was inspired by VueJS to build HTML elements into reusable areas.

A component is a reusable group of elements, like you want to create a button and want to reuse it in your application on various places. So we will create a button component and tell Laravel to grab it whenever we want to use it.

Source

Vue 组件

如今构建单页应用程序非常普遍。前端框架附带了工具和样板,可以支撑启动项目,这些项目大多数时候都是单个页面应用程序。

但是,随着应用程序的发展,您会添加更多功能和更多页面,因此您的 SPA 会变得更难以管理。

One of the great things about working with Vue is its component-based approach to building user interfaces. This allows you to break your application into smaller, reusable pieces (components) which you can then use to build out a more complicated structure. It just makes everything easier. Each component has its own individual set of JS and CSS that it relies on. They are completely independent.

Source

在哪种情况下,您更喜欢 Laravel Blade 组件而不是 Vue 组件,反之亦然?

使用 Blade 或 Vue 组件的大部分决定取决于个人品味和开发团队的品味。 Blade 和 vue 都可以用来创建健壮的、经过充分测试的 Laravel 应用程序。只要您专注于组件的职责,您就会发现使用 Blade 和 Vue 组件之间几乎没有实际差异。

关于javascript - laravel Blade 组件和 vue 组件有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59928056/

相关文章:

javascript - 我应该为此使用缓存吗?

javascript - 将 Javascript 变量返回给 AppleScript

php - 带逗号和点的商业圆

javascript - Laravel 5.1 - 将表单插入表单(Blade)

javascript - 谷歌地图设置 DirectionsRenderer 对象的方向不绘制路线

javascript - Google map 显示多张 map 而不是一张

php - 在 Woocommerce 3 中访问订单项目保护数据

javascript - 从 3.x 升级到 PHP 5.5 后,它似乎试图解析我的 JavaScript 注释(嵌入 PHP 包含文件中的脚本标记中)

php - 查询不起作用。在 Laravel 中找不到页面

sql - 连接被拒绝:Laravel