Skip to content

Commit

Permalink
0.6.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Liang Xingchen committed Nov 24, 2016
1 parent 7ad33f6 commit 759975b
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
4 changes: 3 additions & 1 deletion README.md
Expand Up @@ -679,7 +679,7 @@ class Index extends Component{}

#### 4. defaultProps

强将组件类中的 `props={};` 更新为 `static defaultProps={}`;
请将组件类中的 `props={};` 更新为 `static defaultProps={}`;

#### 5. setState

Expand Down Expand Up @@ -778,6 +778,8 @@ import wx, { Component } from 'labrador-immutable';
</view>
```

> 我们另外提供了Labrador升级工具,[labrador-upgrade](https://github.com/maichong/labrador-upgrade) 可以快速升级项目代码。
## ChangeLog

#### 2016-10-09
Expand Down
8 changes: 8 additions & 0 deletions component.js
Expand Up @@ -83,6 +83,11 @@ export default class Component {
* @param {function} [callback]
*/
setState(nextState: $DataMap, callback?: Function): void {
if (__DEV__) {
if (typeof nextState === 'string') {
console.error(this.id + '#setState() 第一个参数不能为字符串');
}
}
if (!this._inited) {
console.error(this.id + ' 组件未自动初始化之前请勿调用setState(),如果在组件构造函数中请直接使用"this.state={}"赋值语法');
}
Expand Down Expand Up @@ -154,6 +159,9 @@ export default class Component {
if (this._inited) return;
this._setKey(key, parent, listIndex, listKey);
if (__DEV__) {
if (this.data) {
console.error(this.id + ' Component data属性和 setData方法已经废弃,请使用state 和 setState代替');
}
console.log('%c%s init %o', 'color:#9a23cc', this.id, this);
}
// console.log(this.path + '#init', this);
Expand Down
17 changes: 17 additions & 0 deletions index.js
Expand Up @@ -35,6 +35,23 @@ const labrador = {
}
};

if (__DEV__) {
Object.defineProperty(labrador, 'Component', {
get(){
console.error('labrador 0.6版本之后废弃了 wx.Component,请使用 ' +
'"import wx, { Component, PropsTypes } from \'labrador\'" 代替 ' +
'"import wx from \'labrador\'"');
}
});
Object.defineProperty(labrador, 'PropsTypes', {
get(){
console.error('labrador 0.6版本之后废弃了 wx.PropsTypes,请使用 ' +
'"import wx, { Component, PropsTypes } from \'labrador\'" 代替 ' +
'"import wx from \'labrador\'"');
}
});
}

Object.keys(wx).forEach((key) => {
if (
noPromiseMethods[key] // 特别指定的方法
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "labrador",
"version": "0.6.3",
"version": "0.6.4",
"description": "微信小程序模块化开发框架",
"keywords": [
"wxa",
Expand Down

0 comments on commit 759975b

Please sign in to comment.