Laravel 拥有基于 Vue 组件的 Blade 组件,您甚至可以在 Laravel 中使用 Vue 组件。那么他们两者有什么区别呢?当你必须互相使用时,即在这种情况下,你会更喜欢 Laravel Blade 组件而不是 Vue 组件,反之亦然。
最佳答案
基于组件的方法
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.
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.
在哪种情况下,您更喜欢 Laravel Blade 组件而不是 Vue 组件,反之亦然?
使用 Blade 或 Vue 组件的大部分决定取决于个人品味和开发团队的品味。 Blade 和 vue 都可以用来创建健壮的、经过充分测试的 Laravel 应用程序。只要您专注于组件的职责,您就会发现使用 Blade 和 Vue 组件之间几乎没有实际差异。
关于javascript - laravel Blade 组件和 vue 组件有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59928056/