-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[vue] vue在组件中引入插件的方法有哪些? #271
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
不是很明白题主的意思, 先mark一下 |
现在随着组件库越来越多,插件好像就用得少了。 |
插件插件通常用来为 Vue 添加全局功能。插件的功能范围没有严格的限制——一般有下面几种:
示例:安装 ElementUI
|
Vue.use(xx) |
npm安装,在main.js里import,然后Vue.use(xx)后便可全局使用, |
Vue.use(xx)=》注册插件 |
全局引入:将插件在应用的入口文件中全局引入,使其在所有组件中可用。在main.js或类似的入口文件中使用Vue.use()方法引入插件。
引入后,插件中的组件、指令、过滤器等将在整个应用范围内可用。 局部引入:在需要使用插件的组件中进行局部引入。可以在组件的<script>块中使用import语句引入插件,然后在components选项或directives选项中使用。
使用局部引入时,插件中的组件、指令等仅在该组件及其子组件中可用。 插件选项引入:一些插件允许通过传递选项来进行引入和配置。可以在组件的选项中通过plugins属性来引入插件并进行配置。
这种方式允许对插件进行更细粒度的配置。 |
[vue] vue在组件中引入插件的方法有哪些?
The text was updated successfully, but these errors were encountered: