vue进行跳转之后出现Cannot read properties of undefined (reading 'router') TypeError: Cannot read properties of undefined (reading 'router'的问题

发布时间 2023-10-18 17:08:51作者: yesyes1

问题描述

使用router进行页面跳转时,就出现了这样的问题:

也就是这里出现了问题:

问题解决

本来是按照网上的教程:

const _this=this;

但是,但是,我本来就是用的这种方法呀~

然后就打算直接在这个界面引用:

import router from '@/router'

router.push('/one');

里面引用的跳转页面链接必须为我们在index.js页面里面定义的呦~

改成这样子,就ok啦~

终于解决啦(添加成功!):