'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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import Vue from 'vue'
 
import {
  parsePage
} from './parser/page-parser'
 
import {
  parseComponent
} from './parser/component-parser'
 
import {
  handleRelations
} from './polyfill/relations'
 
import polyfill from './polyfill/index'
 
global.__wxRoute = ''
global.__wxComponents = Object.create(null)
global.__wxVueOptions = Object.create(null)
 
export function Page (options) {
  const pageOptions = parsePage(options)
  pageOptions.mixins.unshift(polyfill)
  pageOptions.mpOptions.path = global.__wxRoute
  global.__wxComponents[global.__wxRoute] = pageOptions
}
 
function initRelationsHandler (vueComponentOptions) {
  // linked 需要在当前组件 attached 之后再执行
  if (!vueComponentOptions.onServiceAttached) {
    vueComponentOptions.onServiceAttached = []
  }
  vueComponentOptions.onServiceAttached.push(function onServiceAttached () {
    handleRelations(this, 'linked')
  })
}
 
export function Component (options) {
  const componentOptions = parseComponent(options)
  componentOptions.mixins.unshift(polyfill)
  componentOptions.mpOptions.path = global.__wxRoute
  initRelationsHandler(componentOptions)
  global.__wxComponents[global.__wxRoute] = componentOptions
}
 
export function Behavior (options) {
  return options
}
 
export const nextTick = Vue.nextTick
 
export default uni.__$wx__