search

Home  >  Q&A  >  body text

javascript - props in json format in vue force toString to be called "[object Object]"

<template>
  <AboutConfirm :projects="projects"/>
</template>

<script>
  import AboutConfirm from '../../components/HomePage/AboutConfirm.vue'
  export default{
    data(){
      return {
        projects:[],
        projectsStr:''
      }
    },
    components: {
      AboutConfirm
    },
    created: function () {
      this.projects = this.$route.query
      this.projectsStr = JSON.stringify(this.$route.query)
    },
    beforeMount(){
      console.log('beforeMount');
      console.log('this.projects--------------');
      console.log(this.projects);
//      console.log(JSON.this.projectsStr);
      let url = SERVER.api.getMyProject
      PM.fnRequestAjax(url, null, 'get', (data) => {
//        this.projects = data.data.not_process
//        console.log('data.data.not_process');
//        console.log(data.data.not_process);
      })
    },
    mounted(){

    },
    updated(){
      console.log('updated');
    },
    activated(){
      console.log('activated');
    }
  }
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
</style>

When jumping to other pages and calling window.history.go(-1) again, the data read in beforeMount becomes "[object Object]"

巴扎黑巴扎黑2840 days ago689

reply all(2)I'll reply

  • 漂亮男人

    漂亮男人2017-05-19 10:26:32

    [object object] is the default return value of the object toString() method
    You should use JSON.stringify(obj) ;

    reply
    0
  • 漂亮男人

    漂亮男人2017-05-19 10:26:32

    No one knows what projects have gone through

    reply
    0
  • Cancelreply