'f'
mh-two-thousand-and-two
2024-04-12 26f2711ef9461961fb953e2b497bd314ef95e345
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import {
  instances
} from './util'
 
import parseBasePage from '../../../mp-weixin/runtime/wrapper/page-base-parser'
 
export default function parsePage (vuePageOptions) {
  const pageOptions = parseBasePage(vuePageOptions)
  // 页面需要在 ready 中触发,其他组件是在 handleLink 中触发
  pageOptions.lifetimes.ready = function ready () {
    if (this.$vm && this.$vm.mpType === 'page') {
      this.$vm.__call_hook('created')
      this.$vm.__call_hook('beforeMount')
      this.$vm._isMounted = true
      this.$vm.__call_hook('mounted')
      this.$vm.__call_hook('onReady')
    } else {
      this.is && console.warn(this.is + ' is not ready')
    }
  }
 
  pageOptions.lifetimes.detached = function detached () {
    this.$vm && this.$vm.$destroy()
    // 清理
    const pageId = this.pageinstance.__pageId__
    Object.keys(instances).forEach(key => {
      if (key.indexOf(pageId + '_') === 0) {
        delete instances[key]
      }
    })
  }
 
  return pageOptions
}