读取JavaScript对象中的对象属性值(Reading object property value in JavaScript object)
我正在尝试读取以下JavaScript对象的username属性并将其存储在变量中。
[ RowDataPacket { username: 'admin', password: 'admin' } ]
它作为结果对象从SQL查询返回给用户数据库。 返回的对象称为
result
然而,当我尝试访问它的属性var sqlusername = result.username
要么
var sqlusername = result.RowDataPacket.username
要么
var sqlusername = result["username"]
或任何其他方式访问该财产,
变量var的值总是未定义的。
如何使用对象的用户名和密码属性?
I am trying to read the username property of the following JavaScript object and store it inside a variable.
[ RowDataPacket { username: 'admin', password: 'admin' } ]
It is being returned as a result object from an SQL query to a user database. The returned object is called
result
However, when I try to access its properties withvar sqlusername = result.username
or
var sqlusername = result.RowDataPacket.username
or
var sqlusername = result["username"]
or any other way to access the property,
the value of the variable var is always undefined.
How do I use the username and password properties of the object?
原文:https://stackoverflow.com/questions/49566257
满意答案
摆脱那个网格组件。 你不需要这么简单的事情。 这是复杂的事情,因为它不是一个常规/常见的组件,我们不知道它是如何影响事物的。
这看起来很简单:
<View> <View style={{}}> <Image /> </View> <View style={{flexDirection:'row'}}> <View> <Text>row 1, col 1</Text> </View> <View> <Text>row 1, col2Text> </View> </View> <View style={{flexDirection:'row'}}> <View> <Text>row 2, col 1</Text> </View> <View> <Text>row 2, col2Text> </View> </View> <View style={{}}> <Button title="Login" /> </View> </View>
这里有另外一个类似的问题 - 如何在没有第三方库的情况下创建3x3网格菜单?
Get rid of that grid component. You don't need it for such a simple thing. It's complicating things, and as it's not a regular/common component we don't know how it's affecting things.
This looks quite simple:
<View> <View style={{}}> <Image /> </View> <View style={{flexDirection:'row'}}> <View> <Text>row 1, col 1</Text> </View> <View> <Text>row 1, col2Text> </View> </View> <View style={{flexDirection:'row'}}> <View> <Text>row 2, col 1</Text> </View> <View> <Text>row 2, col2Text> </View> </View> <View style={{}}> <Button title="Login" /> </View> </View>
Here's another similar question - How to create 3x3 grid menu in react native without 3rd party lib?
相关问答
更多如何动态调整标题的徽标?(how can resize dynamically the logo of the header?)
徽标浮在标题上方或上方(Logo floating over or above header)
如何在顶部使用徽标标题来制作此网格?(How to make this grid with logo header at the top?)
Sticky Header Logo Hover [关闭](Sticky Header Logo Hover [closed])
徽标没有显示在标题img的顶部(Logo not showing on top of header img)
在标题中的同一行上创建徽标和链接(Make the logo and links on the same line in header)
在标题中添加徽标和其他图像(Adding Logo and other image in header)
在标题顶部移动div(Moving div on top of header)
如何在Wordpress中使用CSS修复标题高度和调整徽标大小(How to fix header height and resize logo with CSS in Wordpress)
对齐标题和徽标(Align Header and logo)
相关文章
更多Object Oriented Programming
Cannot expose request attribute 'website' because of an existing model object of the same name 的解决方案
Guava学习笔记:复写的Object常用方法
javascript 问题
从 prototype.js 深入学习 javascript 的面向对象特性
javascript 对象转换成json格式数据(使用JSON.stringify)
javascript快速入门
javascript常用对象
javascript函数与对象
孔浩javascript设计模式视频教程
最新问答
更多获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
如何通过引用返回对象?(How is returning an object by reference possible?)
矩阵如何存储在内存中?(How are matrices stored in memory?)
每个请求的Java新会话?(Java New Session For Each Request?)
css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
xcode语法颜色编码解释?(xcode syntax color coding explained?)
在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
Copyright ©2023 peixunduo.com All Rights Reserved.粤ICP备14003112号
本站部分内容来源于互联网,仅供学习和参考使用,请莫用于商业用途。如有侵犯你的版权,请联系我们(neng862121861#163.com),本站将尽快处理。谢谢合作!