javascript - 在网页上显示后端响应
问题描述
我是新手,请善待!
如何将控制台中返回给我的对象的值传输到网页?截至目前,余额值在控制台中,但未显示在页面上。
编辑:如果我想在控制台中单独显示对象,我是否使用 myObj.key?例如。我想在我的网页左侧显示 balance 的值,在右侧显示 block 的值,我是否使用 myObj.balance 和 myObj.block ?
这是我的代码,请指导我,谢谢!
<template>
<div class="box-card">
<p class="title-text">余额</p>
<p class="number-text">{{Balance}}</p>
</div>
</template>
<script>
export default {
data() {
return {
userId: 0,
// page config
currentPage: 1,
total: 0,
pageSize: 20,
userBalance: [],
Balance: '',
}
},
watch: {},
mounted() {
this.userId = this.$route.query["user_id"];
this.userId = 41;
this.getUserBalance();
this.getUserIncomeRecord();
console.log('hello');
},
methods: {
pageChange(val) {
this.currentPage = val;
},
getUserBalance() {
Core.Api.User.getUserBalance(this.userId).then(res => {
console.log(res);
res == this.Balance;
})
},
</script>
解决方案
已编辑:如果您想在具有特定 ID 的元素中打印而不是console.log("WHAT YOU WANT TO PRINT")
使用此:
document.getlementById("YOUR ELEMENT ID HERE").innerHtml("WHAT YOU WANT TO PRINT");
如果你使用Jquery,这相当于上面的代码:
$("#ELEMENT ID HERE").html("WHAT YOU WANT TO PRINT");
推荐阅读
- python - 在 Flask 路由上出现未找到的错误?
- android - 使用 GoogleApiClient 获取坐标 xperia (android 8) 的麻烦
- c# - 检查是否在 C# 中选择了所有单选按钮
- python - 如何在 Keras 中累积大批量的梯度
- javascript - 将消息从属性文件传递到struts中的javascript
- python - 正确实现 scipy.optimize 以求解平面方程的所有参数
- augmented-reality - 如何在 Android Studio 的 ARcore 中设置投影矩阵远裁剪平面参数
- scala - 单个特征与 mixin 的实例化
- facebook-graph-api - Instagram Graph API - 当用户从个人账户切换到企业账户时获取媒体洞察指标
- laravel - 如何在 Laravel 中将三个多对多关系结果组合成一个集合?