收藏
回答

小程序云开发中数据库操作时提示 _ is not defined如何解决?

开发者工具 1.03.2010232

基础库 2.13.2

在使用微信小程序云开发时,数据库的一些操作方法中, 常规操作时可以执行的。 但是带有`_`的操作就直接报错了

```

MiniProgramError

_ is not defined

ReferenceError: _ is not defined

    at $A.onLoad (http://127.0.0.1:44336/appservice/__APP__/appservice.js:10306:18)

    at $A.<anonymous> (http://127.0.0.1:44336/appservice/__dev__/WAService.js:2:3202634)

    at $A.l.__callPageLifeTime__ (http://127.0.0.1:44336/appservice/__dev__/WAService.js:2:3202379)

    at Ne (http://127.0.0.1:44336/appservice/__dev__/WAService.js:2:3218135)

    at http://127.0.0.1:44336/appservice/__dev__/WAService.js:2:3221713

    at Oe (http://127.0.0.1:44336/appservice/__dev__/WAService.js:2:3222246)

    at Function.<anonymous> (http://127.0.0.1:44336/appservice/__dev__/WAService.js:2:3231964)

    at i.<anonymous> (http://127.0.0.1:44336/appservice/__dev__/WAService.js:2:3193323)

    at i.emit (http://127.0.0.1:44336/appservice/__dev__/WAService.js:2:1617415)

    at Object.emit (http://127.0.0.1:44336/appservice/__dev__/WAService.js:2:1576063)

```


代码片段如下

```js

onLoad: function (options) {

console.log(options.room_id)

let that = this

wx.cloud.database()

.collection("rooms")

.where({

room_id:options.room_id,

room_name:_.eq("23")

})

.get({

success: function(res){

that.setData({room:res.data[0]})

}

})

},


```

回答关注问题邀请回答
收藏

1 个回答

登录 后发表内容
问题标签