非常简单的一个模板, 想拿一下路由上的参数就会报如下这个错误
[Vue warn]: Property or method "toJSON" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property.
但是console.log的东西,是可以打印出来的
地址栏是:
xxx.xxx.com/#/loading?ck=123456&id=123456
下面是我的代码
<template>
<div class="loadpay">
<v-header title='加载中...' text='首页' @back="back" ref='header' style="z-index:9">
<i class="iconfont icon-jiantouzuo" slot='back'></i>
</v-header>
<div>
<img src='../../assets/images/loading.png'>
</div>
</div>
</template>
<script>
import vHeader from 'components/header'
import {getUrl, getCode} from 'utils/axios'
export default {
name: 'loadpay',
components: {
vHeader
},
mounted () {
console.log(this.$route)
},
methods: {
back () {
this.$router.push({
path: '/'
})
}
}
}
</script>
<style lang="scss" scoped>
@import '~styles/variables.scss';
.loadpay{
text-align: center;
width: 100%;
img{
padding-top: 5rem;
width: 40%;
}
}
</style>
求各路大神解决办法.
通过路由获取参数,这种形式this.$route.toJSON是吗?如果是,你需要在上一级跳转的路由,把toJSON这个参数写在路由里面。如下: