Vue-Router通过道具传递数据

Vue.js

Mandy西门

2020-03-16

我在使用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”未在实例上定义,但在渲染期间被引用。确保在data选项中声明反应性数据属性。

顺便说一下,我要路由的组件看起来像这样:

<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'],
   }
 }
}

第1726篇《Vue-Router通过道具传递数据》来自Winter(https://github.com/aiyld/aiyld.github.io)的站点

0个回答

问题类别

JavaScript Ckeditor Python Webpack TypeScript Vue.js React.js ExpressJS KoaJS CSS Node.js HTML Django 单元测试 PHP Asp.net jQuery Bootstrap IOS Android