Type Error in .then function using Vue.js

孤街浪徒 提交于 2021-01-16 03:49:08

问题


I have a get request that detects if user is Admin or not. My problem is that I want to display a button using v-if to check if it's true or false. By default the value is set to false.

Data

Then we got the button :

And the .then in beforeCreate :


回答1:


You need to use an arrow function to preserve the this context:

.then((responses) => {

Otherwise the callback function injects its own this



来源:https://stackoverflow.com/questions/65290912/type-error-in-then-function-using-vue-js

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!