You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

17 lines
521 B

2 years ago
  1. // 1.导入 countStore
  2. import { counterStore } from './store/counter'
  3. // 2.导入中间件,连接mobx、react,完成响应式变化
  4. import { observer } from 'mobx-react-lite'
  5. function App () {
  6. return (
  7. <div className="App">
  8. {/* 把 store 中的 count */}
  9. {counterStore.count}
  10. <br />
  11. {/* 点击事件触发 action 函数修改 count 值 */}
  12. <button onClick={counterStore.addCount}>+</button>
  13. </div>
  14. )
  15. }
  16. export default observer(App)