我需要从Account控制器方法获取值并将其放入vuejs变量中。很有可能可以更正确地完成此操作,我不介意听一听。
问题在于,在console.log
中,它返回十进制,然后返回。如何获得responseText?
return: {
"readyState": 4,
"responseText": "56.00",
"responseJSON": 56,
"status": 200,
"statusText": "success"
}
[HttpGet]
public async Task<decimal> GetUserBalance(string userEmail)
{
User user = await _userManager.FindByEmailAsync(userEmail);
return user.Balance;
}
vuejs和ajax
var app5 = new Vue({
el: '#balance',
data: {
balance: $.ajax({
type: "GET",
url: '/Account/GetUserBalance',
data: { userEmail: '@User.Identity.Name' },
async: true,
dataType: 'JSON',
success: function (value) {
console.log(value);
return value;
}
})
},