【发布时间】:2017-12-13 13:34:33
【问题描述】:
我很难使用 Vue-Router 传递道具。当我将它们带入下一个视图时,我似乎无法访问这些道具。这是我的方法对象:
methods: {
submitForm() {
let self = this;
axios({
method: 'post',
url: url_here,
data:{
email: this.email,
password: this.password
},
headers: {
'Content-type': 'application/x-www-form-urlencoded; charset=utf-8'
}
}).then(function(response) {
self.userInfo = response.data;
self.$router.push({name: 'reading-comprehension', props: {GUID:self.userInfo.uniqueID }});
})
}
}
发布请求正在工作,但是当我尝试路由到一个新组件并传递一个道具以访问下一个组件时,它说,
属性或方法“guid”未在实例上定义,但 在渲染期间引用。确保声明反应数据 数据选项中的属性。
顺便说一下,我要路由到的组件如下所示:
<template lang="html">
<div class="grid-container" id="read-comp">
<div class="row">
<h1>Make a sentence:</h1>
{{ GUID }}
</div>
</div>
</template>
<script>
export default {
data(){
return {
props: ['GUID'],
}
}
}
【问题讨论】:
标签: vue.js vuejs2 vue-component axios vue-router