是否可以从插件中调用vue组件中的where方法



我想访问插件中的vue.data或方法
不管我试了几次,都没用
例如eventBus、Mixin等。
所以我很好奇是否有可能调用这样的方法
感谢您阅读此问题。

这是自定义组件。

<template>
<div>
<v-overlay :value="isProcessing">
<v-progress-circular indeterminate size="64"></v-progress-circular>
</v-overlay>
</div>
</template>
<script lang="ts">
import { Component, Vue } from 'vue-property-decorator';
@Component
export default class ProgressCircular extends Vue {
private isProcessing: boolean;
startProcess() {
this.isProcessing = true;
}
}
</script>

这就是插件的来源。

import ProgressCircular from '@/components/ProgressCircular.vue';
import { VueConstructor } from 'vue';
import Vuetify from 'vuetify/lib';
import vuetify from './vuetify';
export default {
install(Vue: VueConstructor, options: any = {}) {
Vue.use(Vuetify);
options.vuetify = vuetify;
Vue.component('progress-circular', ProgressCircular);
Vue.prototype.$fireProgressing = function () {
// it didn't work
// I just wanted to access the method where in the Vue Component
// ProgressCircular.startProcess();
};
},
};

使用插件语法来扩展vue-like:

Vue.use({
install: Vue => {
Vue.prototype.$fireProgressing = () => {
};
}
});

Vue.use(YOURPLUGIN);

在安装vue 之前

最新更新