-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[vue] 组件和插件有什么区别? #283
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
组件 (Component) 是用来构成你的 App 的业务模块,它的目标是 App.vue。 插件 (Plugin) 是用来增强你的技术栈的功能模块,它的目标是 Vue 本身。 |
学到了 |
学到了 |
组件组件是Vue中最基本的构建单元,用于封装可重用的代码和功能。一个组件通常包含了模板、数据、方法和样式等,用于定义一个独立的UI单元。组件可以在应用中多次实例化和重复使用,从而实现代码的模块化和复用。通过组件可以构建复杂的页面结构,提高代码的可维护性和可扩展性。
插件插件是一种扩展Vue功能的方式,可以通过全局方式或局部方式进行安装。插件可以添加全局方法、指令、混入等,以实现对Vue的功能扩展或提供额外的功能。插件通常以函数或对象的形式存在,可以在Vue实例中通过Vue.use()方法来安装插件,并在整个应用范围内使用插件提供的功能。
总结组件用于封装可重用的UI代码和功能,通过组合和复用来构建复杂的页面结构;而插件用于扩展Vue的功能,提供全局方法、指令、混入等额外的功能,以满足特定的需求。 |
[vue] 组件和插件有什么区别?
The text was updated successfully, but these errors were encountered: