這個問題在這里已經有了答案:
因此獲取 id 或任何其他資料如下:
console.log(this.$user.id);
不起作用
我有什么辦法可以解決這個問題?
uj5u.com熱心網友回復:
您必須通過JSON.parse()
更改此行將字串決議為 JSON 物件:
Vue.prototype.$user = document.querySelector("meta[name='user']").getAttribute('content')
到:
Vue.prototype.$user = JSON.parse(document.querySelector("meta[name='user']").getAttribute('content'))
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/359409.html
標籤:拉拉维尔 Vue.js laravel-sanctum
上一篇:如何解決v-slotvuejes上的打字稿TS7031錯誤?
下一篇:如何從Vue中的陣列中洗掉專案
