搜索

首页  >  问答  >  正文

javascript - vue中json格式的props强制调用了toString变为"[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>

当跳转到其他页面,再调用window.history.go(-1),在beforeMount中的读到的数据变为"[object Object]"

巴扎黑巴扎黑2840 天前684

全部回复(2)我来回复

  • 漂亮男人

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

    [object object] 是 对象 toString() 方法的默认返回值
    你应该用 JSON.stringify(obj) ;

    回复
    0
  • 漂亮男人

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

    没有人知道projects经历了什么

    回复
    0
  • 取消回复