Subscribe on changes!

Cannot read properties of undefined (reading 'push')

avatar
Apr 8th 2022

Version

3.2.31

Reproduction link

github.com stackblitz.com

Steps to reproduce

install

pnpm install

run

pnpm run dev

You can see this error, it will appear in the console

The error code is in "src/pages/index.vue"

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'push')      index.vue:92 
     at initSplashStage (index.vue:92:3)
     at initStages (index.vue:43:3)
     at index.vue:31:3
     at callWithErrorHandling (runtime-core.esm-bundler.js:155:22)
     at callWithAsyncErrorHandling (runtime-core.esm-bundler.js:164:21)
     at Array.hook.__weh.hook.__weh(runtime-core.esm-bundler.js:2667:29)
     at flushPostFlushCbs (runtime-core.esm-bundler.js:356:32)
     at flushJobs (runtime-core.esm-bundler.js:401:9)

I have tried many methods, but either there is no way to push in, or the display is null and cannot use other APIs

What is expected?

element push in

What is actually happening?

Cannot read properties of undefined (reading 'push')

avatar
Apr 8th 2022

This is not a minimal reproduction. Please boil your problem down to a minimum demo that doesn't involve external dependencies.

If you need help with your specific code and this "SplashStage" thing, maybe ask the community for help first. chat.vuejs.org

avatar
Jun 25th 2022

function1:

import { useRouter } from 'vue-router';
export default {
  setup() {
    // 第一步将useRouter函数执行放在顶部
    const router = useRouter();
    // 第二步在方法里面调用router 
    function toPage(){
      router.push("/about");
    }
    return {
       toPage
    }
  }
}

funtion2:

import router from "@/router/index.ts";
router.push("/");