Commit e4374ec4 authored by AU-PRO's avatar AU-PRO

for learning code

parent f843f3bd
...@@ -5,14 +5,22 @@ const showPop1 = () => { ...@@ -5,14 +5,22 @@ const showPop1 = () => {
} }
const showPop2 = () => { export const showPop2 = () => {
} }
const test01 = (num) => { export const testGet = () => {
popState.popStateAdd(num) return popState.testNum
}
export const testComputed = (num) => {
// console.log()
return popState.computed4test
}
export const testSet = (num) => {
return popState.add(num)
} }
// export default showPop1 // export default showPop1
// export default showPop2 // export default showPop2
export default test01 \ No newline at end of file
\ No newline at end of file
export { default as AUPOP } from './apiFunction' export * as AUPOP from './apiFunction'
\ No newline at end of file \ No newline at end of file
...@@ -8,6 +8,7 @@ class PopState { ...@@ -8,6 +8,7 @@ class PopState {
constructor() { constructor() {
makeAutoObservable(this, { makeAutoObservable(this, {
nowShow: observable, nowShow: observable,
testNum: observable,
computed4test: computed, computed4test: computed,
add: action add: action
}) })
...@@ -18,21 +19,17 @@ class PopState { ...@@ -18,21 +19,17 @@ class PopState {
popArr = [] popArr = []
add = (num) => { add = (num) => {
this.nowShow += num this.testNum += num
} }
computed4test = () => { testNum = 0
console.log('nowShow is: ', this.nowShow)
return `nowShow is : ${this.nowShow}` get computed4test () {
console.log('testNum is: ', this.testNum)
return `testNum is : ${this.testNum}`
} }
} }
const AUPopState = new PopState() const AUPopState = new PopState()
const popStateAdd = (num) => { export default AUPopState
AUPopState.add(num)
}
export default {
popStateAdd
}
...@@ -62,7 +62,10 @@ class PageHome extends Component { ...@@ -62,7 +62,10 @@ class PageHome extends Component {
} }
mobxAction01 = () => { mobxAction01 = () => {
AUPOP.test01(1) console.log('AUPOP is: ', AUPOP)
AUPOP.testSet(1)
console.log('AUPOP.testGet::::: ', AUPOP.testGet())
console.log('AUPOP.testComputed::::: ', AUPOP.testComputed())
} }
openColorful = () => { openColorful = () => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment