提交 7c29970a 编写于 作者: fxy060608's avatar fxy060608

Merge branch 'dev' of https://github.com/dcloudio/uni-app into v3

此差异已折叠。
import {
hasOwn
} from 'uni-shared'
import { import {
isPage, hasOwn
} from 'uni-shared'
import {
isPage,
initRelation initRelation
} from './util' } from './util'
import parseBaseComponent from '../../../mp-weixin/runtime/wrapper/component-base-parser' import parseBaseComponent from '../../../mp-weixin/runtime/wrapper/component-base-parser'
export default function parseComponent (vueOptions) { const newLifecycle = swan.canIUse('lifecycle-2-0')
export default function parseComponent(vueOptions) {
const componentOptions = parseBaseComponent(vueOptions, { const componentOptions = parseBaseComponent(vueOptions, {
isPage, isPage,
initRelation initRelation
...@@ -17,19 +19,32 @@ export default function parseComponent (vueOptions) { ...@@ -17,19 +19,32 @@ export default function parseComponent (vueOptions) {
const oldAttached = componentOptions.lifetimes.attached const oldAttached = componentOptions.lifetimes.attached
componentOptions.lifetimes.attached = function attached () { componentOptions.lifetimes.attached = function attached() {
oldAttached.call(this) oldAttached.call(this)
if (isPage.call(this)) { // 百度 onLoad 在 attached 之前触发 if (isPage.call(this)) { // 百度 onLoad 在 attached 之前触发
// 百度 当组件作为页面时 pageinstancce 不是原来组件的 instance // 百度 当组件作为页面时 pageinstancce 不是原来组件的 instance
this.pageinstance.$vm = this.$vm this.pageinstance.$vm = this.$vm
if (hasOwn(this.pageinstance, '_$args')) { if (hasOwn(this.pageinstance, '_$args')) {
this.$vm.$mp.query = this.pageinstance._$args this.$vm.$mp.query = this.pageinstance._$args
this.$vm.__call_hook('onLoad', this.pageinstance._$args) this.$vm.__call_hook('onLoad', this.pageinstance._$args)
delete this.pageinstance._$args delete this.pageinstance._$args
} }
// TODO 目前版本 百度 Component 作为页面时,methods 中的 onShow 不触发 // TODO 3.105.17以下基础库内百度 Component 作为页面时,methods 中的 onShow 不触发
this.$vm.__call_hook('onShow') !newLifecycle && this.$vm.__call_hook('onShow')
}
}
if (newLifecycle) {
delete componentOptions.lifetimes.ready
componentOptions.methods.onReady = function() {
if (this.$vm) {
this.$vm._isMounted = true
this.$vm.__call_hook('mounted')
this.$vm.__call_hook('onReady')
} else {
// this.is && console.warn(this.is + ' is not attached')
}
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册