vue.js - 路由器视图外的Vue路由返回空数据
问题描述
我正在努力在<router-view>
组件之外获取 Vue 路由。在里面,它工作正常。
情况很奇怪,因为结果是这样的:
mounted : function()
{
console.log(this.$router);
},
它显示了这一点:
currentRoute: Object
fullPath: "/activity-calendar"
hash: ""
matched: [{…}]
meta: {__ob__: Observer}
name: "Activity calendar"
params: {}
path: "/activity-calendar"
query: {}
这是对的。但是,当我尝试通过
console.log(this.$router.currentRoute);
我得到:
fullPath: "/"
hash: ""
matched: []
meta: {}
name: null
params: {}
path: "/"
query: {}
怎么,对象不一样?
解决方案
推荐阅读
- python-3.x - 使用 Python 绘制 3D 散点图仅返回一个空白区域(Jupyter Notebook)
- javascript - 在点击事件时从本地存储更改值并不总是有效
- java - 如何知道 Future 是用 Callable 还是 Runnable 创建的
- karate - 如何在空手道功能文件中转义“(”
- python - 如何扩展/分隔成多行
- java - Jetty JNDI 资源失败:“java.lang.ClassNotFoundException: oracle.jdbc.pool.OracleDataSource”
- c# - 从 GraphicsCapturePicker 选取的 GraphicsCaptureItem 中获取 HWND
- javascript - 使用 node.js 谷歌云语音转文本,如何获取当前工作的状态?
- docker - 如何通过网络服务器从 docker 容器中公开文件
- html - 表单 CSS 不会改变