1 | import OurVue from 'vue';
|
2 | import { consoleError } from './util/console';
|
3 | export function install(Vue, args = {}) {
|
4 | if (install.installed) return;
|
5 | install.installed = true;
|
6 |
|
7 | if (OurVue !== Vue) {
|
8 | consoleError('Multiple instances of Vue detected\nSee https://github.com/vuetifyjs/vuetify/issues/4068\n\nIf you\'re seeing "$attrs is readonly", it\'s caused by this');
|
9 | }
|
10 |
|
11 | const components = args.components || {};
|
12 | const directives = args.directives || {};
|
13 |
|
14 | for (const name in directives) {
|
15 | const directive = directives[name];
|
16 | Vue.directive(name, directive);
|
17 | }
|
18 |
|
19 | (function registerComponents(components) {
|
20 | if (components) {
|
21 | for (const key in components) {
|
22 | const component = components[key];
|
23 |
|
24 | if (component && !registerComponents(component.$_vuetify_subcomponents)) {
|
25 | Vue.component(key, component);
|
26 | }
|
27 | }
|
28 |
|
29 | return true;
|
30 | }
|
31 |
|
32 | return false;
|
33 | })(components);
|
34 |
|
35 |
|
36 |
|
37 |
|
38 | if (Vue.$_vuetify_installed) return;
|
39 | Vue.$_vuetify_installed = true;
|
40 | Vue.mixin({
|
41 | beforeCreate() {
|
42 | const options = this.$options;
|
43 |
|
44 | if (options.vuetify) {
|
45 | options.vuetify.init(this, options.ssrContext);
|
46 | this.$vuetify = Vue.observable(options.vuetify.framework);
|
47 | } else {
|
48 | this.$vuetify = options.parent && options.parent.$vuetify || this;
|
49 | }
|
50 | }
|
51 |
|
52 | });
|
53 | }
|
54 |
|
\ | No newline at end of file |