2017-03-17 75 views
0

當我console.log(this.user)我得到這個:如何訪問對象中的數據?

Object 
isLoggedIn 
: 
true 
user 
: 
Object 
created_at 
: 
"2017-03-14 09:04:42" 
email 
: 
"[email protected]" 
id 
: 
4 
name 
: 
"user" 
updated_at 
: 
"2017-03-14 09:04:42" 

但是,當我現在嘗試訪問this.data.email我得到了一個未定義。任何建議如何從這個對象得到電子郵件?

因爲在我的模板,我想要做這樣的事情:

<div class="panel-body"> 
     You are logged in! <span>{{ user.email }} </span> 

    </div> 
+2

你試過執行console.log(this.data.user.email)? –

+1

要麼你的對象字符串化或@PetrAdam是正確的:) – Maxime

+0

我試了this.data.user.email和this.user.email沒有任何工作 – None

回答

1

我不知道這是否是你要去工作,但試試這個在您的HTML:

<div class="panel-body"> 
    You are logged in! <span>{{ user.user.email }} </span> 
</div>