unicloud笔记
云函数
遇到的小tips
- Vue判断对象中是否存在某个属性
var obj = {
a:2
};
// 方法一
("a" in obj); // true
("b" in obj); // false
// in 操作符会检查属性是否在对象及其 [Prototype] 原型链中
// 方法二
obj.hasOwnProperty( "a" ); // true
obj.hasOwnProperty( "b" ); // false
//hasOwnProperty(..) 只会检查属性是否在 obj 对象中,不会检查 [Prototype] 链
注来自博客:https://blog.csdn.net/gltncx11/article/details/109491728#:~:text=var%20obj%20%3D%20%7B%20a%3A2%20%7D%3B%20%2F%2F%20%E6%96%B9%E6%B3%95%E4%B8%80,%2F%2F%20true%20obj.hasOwnProperty%20%28%22b%22%29%3B%20%2F%2F%20false%20%2F%2FhasOwnProperty%20%28…%29
-
JavaScript判断对象是否为空对象的几种方法https://blog.csdn.net/MyFuture_MyDream/article/details/116225441
-
关于where属性使用变量进行查询的问题
https://ask.dcloud.net.cn/question/110902 -
云函数怎么传参
https://blog.csdn.net/qq_44163269/article/details/107081572#:~:text=%E4%BC%A0%E5%8F%82%20%E5%9C%A8%E8%B0%83%E7%94%A8%20%E4%BA%91%E5%87%BD%E6%95%B0%E7%9A%84%E6%97%B6%E5%80%99%E6%9C%89%E4%B8%80%E4%B8%AA%20data%20%E8%83%BD%E5%A4%9F%E4%BC%A0%E9%80%92%E5%8F%82%E6%95%B0%20async%20development%28%29%7B%20let,%2F%2F%E4%BC%A0%E9%80%92%20a%3A1%2C%20b%3A2%20%7D%20%7D%29%20console.log%28res%29%20%7D%201 -
跨字段 “或” 操作
const dbCmd = db.command
db.collection('goods').where(dbCmd.or(
{
type: {
memory: dbCmd.gt(8)
}
},
{
type: {
cpu: 3.2
}
}
))
// 查询返回值
{
"data":[{
"type": {
"brand": "A",
"name": "A-01",
"memory": 16,
"cpu": 3.2
},
"category": "computer",
"quarter": "2020 Q2",
"price": 2500
},{
"type": {
"brand": "X",
"name": "X-01",
"memory": 8,
"cpu": 4.0
},
"category": "computer",
"quarter": "2020 Q3",
"price": 6500
}]
}
错误记录
- 对db.conllection .get()后不能.where()
- mg动态绑定图片路径不要忘记v-bind scr属性
否则报错:Computed property “XX“ was assigned to but it has no setter.
解决方法:
https://blog.csdn.net/qq_34250472/article/details/112765285 <view>
中使用v-if需要配对v-else
<view>
<view v-if="userInfo.hasOwnProperty('avatar_file')">
<image class="cu-avatar round search_img" :src="this.userInfo.avatar_file.url"></image>
</view>
<view v-else>
<image src="https://ossweb-img.qq.com/images/lol/web201310/skin/big10001.jpg">
</image>
</view>
</view>