-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
25 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import 'tdesign-web-components/button'; | ||
import 'tdesign-web-components/space'; | ||
|
||
import { autorun } from 'mobx'; | ||
import { Component, tag } from 'omi'; | ||
|
||
import { myStore } from '../store'; | ||
|
||
@tag('t-mobx-child') | ||
export default class TestMobxChild extends Component { | ||
// 子组件的autorun可以注掉 | ||
installed() { | ||
// 如果父子组件都调了autorun,会多次触发,看是否优化 | ||
autorun(() => { | ||
this.update(); | ||
console.log('子组件触发autorun'); | ||
}); | ||
} | ||
|
||
render() { | ||
return <t-space>mobx子组件:{myStore.message}</t-space>; | ||
} | ||
} |