扫描小程序码分享
Behaviors should be constructed with Behavior()
找了好久找到一篇文章说是基础库的问题,升到2.0以上就好了,但是我用的是2.14.4啊
(文章比较久远了:https://blog.csdn.net/redspear119/article/details/83348481)
我的代码是这样用的,跟官网示例一样:
装的包的版本如下:
11 个回答
加粗
标红
插入代码
插入链接
插入图片
上传视频
请具体描述问题出现的流程,并提供能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。
你好,麻烦通过点击下方“反馈信息”按钮,提供出现问题的。
const computedBehavior = require('miniprogram-computed';)
Component({
behaviors: [computedBehavior],
data: {},
watch: {
'a, b': function(a, b) {
this.setData({
sum: a + b
})
},
正在加载...
关注后,可在微信内接收相应的重要提醒。
请使用微信扫描二维码关注 “微信开放社区” 公众号
请具体描述问题出现的流程,并提供能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。
2. npm install --save rfcd
3. npm install --save fast-deep-equal
4. 代码Page改成Component
5. 引入miniprogram-computed
const computedBehavior = require('miniprogram-computed';)
Component({
behaviors: [computedBehavior],
data: {},
watch: {
'a, b': function(a, b) {
this.setData({
sum: a + b
})
},
},
})