component-parser.js 930 字节
Newer Older
1
import parseBaseComponent from '../../../mp-weixin/runtime/wrapper/component-parser'
A
Aero 已提交
2

3 4 5 6 7 8 9
import { isPage } from '../../../mp-weixin/runtime/wrapper/util'

import {
  fixSetDataStart,
  fixSetDataEnd
} from '../../../mp-weixin/runtime/wrapper/fix-set-data'

10 11
export default function parseComponent (vueComponentOptions, needVueOptions) {
  const [componentOptions, vueOptions] = parseBaseComponent(vueComponentOptions, true)
12 13
  const oldAttached = componentOptions.lifetimes.attached
  componentOptions.lifetimes.attached = function attached () {
Q
qiang 已提交
14 15
    // 暂不区分版本
    if (isPage.call(this)) {
16 17 18 19 20 21 22 23
      // 解决快手小程序页面 attached 生命周期 setData 导致数据同步异常的问题
      fixSetDataStart(this)
      setTimeout(() => {
        fixSetDataEnd(this)
      }, 0)
    }
    oldAttached.call(this)
  }
24
  return needVueOptions ? [componentOptions, vueOptions] : componentOptions
25
}