How to use the getCurrentInstance function from vue

Find comprehensive JavaScript vue.getCurrentInstance code examples handpicked from public code repositorys.

42
43
44
45
46
47
48
49
50
51
setup(props) {
  const rootTabs = vue.inject('rootTabs');
  if (!rootTabs) {
    throw new Error(`ElTabBar must use with ElTabs`);
  }
  const instance = vue.getCurrentInstance();
  const getBarStyle = () => {
    let style = {};
    let offset = 0;
    let tabSize = 0;
fork icon3
star icon8
watch icon3

+ 3 other calls in file

158
159
160
161
162
163
164
165
166
167
    hitState: false,
    hover: false,
});
const { currentLabel, itemSelected, isDisabled, select, hoverItem, } = useOption(props, states);
const { visible, hover, } = vue.toRefs(states);
const vm = vue.getCurrentInstance().proxy;
select.onOptionCreate(vm);
vue.onBeforeUnmount(() => {
    const { selected } = select;
    let selectedOptions = select.props.multiple ? selected : [selected];
fork icon1
star icon2
watch icon1

+ 3 other calls in file

27
28
29
30
31
32
33
34
35
36
setup(props) {
    const index = vue.ref(-1);
    const lineStyle = vue.ref({});
    const internalStatus = vue.ref('');
    const parent = vue.inject('ElSteps');
    const currentInstance = vue.getCurrentInstance();
    vue.onMounted(() => {
        vue.watch([() => parent.props.active, () => parent.props.processStatus, () => parent.props.finishStatus], ([active]) => {
            updateStatus(active);
        }, { immediate: true });
fork icon1
star icon2
watch icon1

147
148
149
150
151
152
153
154
155
156
const elForm = vue.inject(elFormKey, {});
const validateState = vue.ref('');
const validateMessage = vue.ref('');
const validateDisabled = vue.ref(false);
const computedLabelWidth = vue.ref('');
const vm = vue.getCurrentInstance();
const isNested = vue.computed(() => {
    let parent = vm.parent;
    while (parent && parent.type.name !== 'ElForm') {
        if (parent.type.name === 'ElFormItem') {
fork icon1
star icon2
watch icon1

115
116
117
118
119
120
121
122
123
124
  message: {}
});
const route = vueRouter.useRoute();
const {
  appContext
} = vue.getCurrentInstance();
const breadcrumbRoutes = vue.computed(() => {
  return breadcrumb.value || route.meta.breadcrumb || route.matched.slice(1).map(_route => {
    return {
      path: _route.path,
fork icon1
star icon1
watch icon4

21
22
23
24
25
26
27
28
29
30
31
32
function useRouter () {
  if (process.env.NODE_ENV !== 'production') {
    throwNoCurrentInstance('useRouter')
  }


  return vue.getCurrentInstance().proxy.$root.$router
}


function useRoute () {
  if (process.env.NODE_ENV !== 'production') {
fork icon0
star icon0
watch icon1

+ 14 other calls in file

726
727
728
729
730
731
732
733
734
735
736
    }
}


function getCurrentManager(vm) {
    if (!vm) {
        vm = vue.getCurrentInstance() || undefined;
    }
    if (!vm) {
        return undefined;
    }
fork icon0
star icon0
watch icon1

+ 15 other calls in file