微信小程序报错 Error: Behaviors should be constructed with Behavior()

迈不过友情╰ 2024-03-24 17:02 68阅读 0赞

报错详情:

  1. VM5982:1458 页面【compenents/test1/test1]错误:
  2. Error: Behaviors should be constructed with Behavior()
  3. at Me (WASubContext.js?t=wechat&s=1681017978566&v=2.11.3:2)
  4. at ze (WASubContext.js?t=wechat&s=1681017978566&v=2.11.3:2)
  5. at Module.t (WASubContext.js?t=wechat&s=1681017978566&v=2.11.3:2)
  6. at yt (WASubContext.js?t=wechat&s=1681017978566&v=2.11.3:2)
  7. at Kt (WASubContext.js?t=wechat&s=1681017978566&v=2.11.3:2)
  8. at test1.js? [sm]:6
  9. at C (wxmodule.patch.js?t=wechat&s=1681017978566&v=2.11.3:1)
  10. at <anonymous>:1455:7
  11. at doWhenAllScriptLoaded (<anonymous>:1532:21)
  12. at Object.scriptLoaded (<anonymous>:1560:5)(env: Windows,mp,1.06.2303220; lib: 2.11.3)

在这里插入图片描述

原来的代码

  1. import {
  2. storeBindingBehavior } from 'mobx-miniprogram-bindings';
  3. import {
  4. store} from '../../store/store';
  5. Component({
  6. // 实现绑定
  7. behaviors: [storeBindingBehavior],
  8. storeBindings: {
  9. store,
  10. // 字段
  11. fields: {
  12. num1: 'num1',
  13. num2: 'num2',
  14. sum: 'sum'
  15. },
  16. // 方法
  17. actions: {
  18. updNum2: 'updNum2'
  19. }
  20. },
  21. })

解决

  • 原因

在这里插入图片描述

  • 修改后的代码
    在这里插入图片描述

结束!!!!!!!


  1. 你会成为你欲望的奴隶,你在放纵中,你会觉得你是自由的,其实你被奴隶了。随心所欲不逾矩。---罗翔老师

发表评论

表情:
评论列表 (有 0 条评论,68人围观)

还没有评论,来说两句吧...

相关阅读