I'm trying to display a value in an object, but I don't know the right syntax to do so.
Given a property of type Object like {"name": "bob", "pets name": "fido"}
How can I display the pets name fido?
I've tried
<div>[[myObject["pets name"]]]</div>
and <div>[[myObject]]["pets name]</div>
and <div>[[myObject.pets name]]</div>
and <div>[[myObject."pets name"]]</div>
I made a workaround to just use a computed binding, but the problem is that sometimes the object is empty, and I only want to display something when it has data.
<div>[[_getPetName(myObj)]]</div>
and
...
properties:{
myObj:{ type: Object, value: {"name":"bob", "pet name":"fido"} }
},
_getPetName: function(myObj){
return myObj['pet name'];
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.