wechat-weapp-mobx icon indicating copy to clipboard operation
wechat-weapp-mobx copied to clipboard

小程序开启增强编译后会有问题

Open yautah opened this issue 5 years ago • 5 comments

如题 开启增强编译后 observable的属性的默认值无效,直接变为undefined或者null

yautah avatar Jun 28 '19 08:06 yautah

在增强编译模式下

class TodoStore { todos = [1,2,3] } decorate(TodoStore,{ todos: observable })

这种写法,todos的默认值会被无情的干成null。

在constructor中给todos赋上初始值倒是可以

yautah avatar Jun 28 '19 08:06 yautah

@yautah 写到 constructor 里可以解决问题吗

windy avatar Jun 28 '19 10:06 windy

@windy 可以

yautah avatar Jul 01 '19 02:07 yautah

@yautah 好的, 了解. 我有空补充一下相关内容.

windy avatar Jul 01 '19 02:07 windy

image

windy avatar Jul 01 '19 02:07 windy