Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
// merge App router params
const app = getApp()
if (
app.$router &&
app.$router.params &&
app.$router.params.query &&
Object.keys(app.$router.params.query).length &&
getCurrentPages().length === 1
) {
Object.assign(this.$component.$router.params, options, app.$router.params.query)
} else {
Object.assign(this.$component.$router.params, options)
}
this.$component.$router.path = getCurrentPageUrl()
// preload
if (cacheDataHas(options[preloadPrivateKey])) {
this.$component.$preloadData = cacheDataGet(options[preloadPrivateKey], true)
} else {
this.$component.$preloadData = null
}
initComponent.apply(this, [isPage])
},
this.$component.__isReady = true
// 页面Ready的时候setData更新,此时并未didMount,触发observer但不会触发子组件更新
// 小程序组件ready,但是数据并没有ready,需要通过updateComponent来初始化数据,setData完成之后才是真正意义上的组件ready
// 动态组件执行改造函数副本的时,在初始化数据前计算好props
if (!isPage) {
const compid = this.data.compid
if (compid) {
propsManager.observers[compid] = {
component: this.$component,
ComponentClass
}
}
const nextProps = filterProps(ComponentClass.defaultProps, propsManager.map[compid], this.$component.props)
this.$component.props = nextProps
} else {
this.$component.$router.path = getCurrentPageUrl()
}
mountComponent(this.$component)
}
this.$component.__isReady = true
// 页面Ready的时候setData更新,此时并未didMount,触发observer但不会触发子组件更新
// 小程序组件ready,但是数据并没有ready,需要通过updateComponent来初始化数据,setData完成之后才是真正意义上的组件ready
// 动态组件执行改造函数副本的时,在初始化数据前计算好props
if (!isPage) {
const compid = this.data.compid
if (compid) {
propsManager.observers[compid] = {
component: this.$component,
ComponentClass
}
}
const nextProps = filterProps(ComponentClass.defaultProps, propsManager.map[compid], this.$component.props, this.data.extraProps)
this.$component.props = nextProps
} else {
this.$component.$router.path = getCurrentPageUrl()
}
mountComponent(this.$component)
}
this.$component.__isReady = true
// 页面Ready的时候setData更新,此时并未didMount,触发observer但不会触发子组件更新
// 小程序组件ready,但是数据并没有ready,需要通过updateComponent来初始化数据,setData完成之后才是真正意义上的组件ready
// 动态组件执行改造函数副本的时,在初始化数据前计算好props
if (!isPage) {
const compid = this.data.compid
if (compid) {
propsManager.observers[compid] = {
component: this.$component,
ComponentClass
}
}
const nextProps = filterProps(ComponentClass.defaultProps, propsManager.map[compid], this.$component.props, this.data.extraProps)
this.$component.props = nextProps
} else {
this.$component.$router.path = getCurrentPageUrl()
}
mountComponent(this.$component)
}
}
this.$component._init(this)
this.$component.render = this.$component._createData
this.$component.__propTypes = ComponentClass.propTypes
if (isPage) {
if (cacheDataHas(PRELOAD_DATA_KEY)) {
const data = cacheDataGet(PRELOAD_DATA_KEY, true)
this.$component.$router.preload = data
}
Object.assign(this.$component.$router.params, options)
if (cacheDataHas(options[preloadPrivateKey])) {
this.$component.$preloadData = cacheDataGet(options[preloadPrivateKey], true)
} else {
this.$component.$preloadData = {}
}
this.$component.$router.path = getCurrentPageUrl()
initComponent.apply(this, [ComponentClass, isPage])
}
},
attached () {
created (options = {}) {
isPage && (hasPageInited = false)
this.$component = new ComponentClass({}, isPage)
this.$component._init(this)
this.$component.render = this.$component._createData
this.$component.__propTypes = ComponentClass.propTypes
Object.assign(this.$component.$router.params, options)
if (isPage) {
if (cacheDataHas(PRELOAD_DATA_KEY)) {
const data = cacheDataGet(PRELOAD_DATA_KEY, true)
this.$component.$router.preload = data
}
this.$component.$router.path = getCurrentPageUrl()
initComponent.apply(this, [ComponentClass, isPage])
}
},
attached () {
const key = keys[i]
if (i === len - 1) return obj[key]
obj = obj[key]
}
}
let id = 0
function genId () {
return String(id++)
}
let compIdsMapper
try {
compIdsMapper = new Map()
} catch (error) {
compIdsMapper = new SimpleMap()
}
export function genCompid (key, isNeedCreate) {
if (!Current || !Current.current || !Current.current.$scope) return []
const prevId = compIdsMapper.get(key)
if (isNeedCreate) {
const id = genId()
compIdsMapper.set(key, id)
return [prevId, id]
} else {
const id = prevId || genId()
!prevId && compIdsMapper.set(key, id)
return [null, id]
}
}
if (res) return res
return null
}
let id = 0
function genId () {
return String(id++)
}
let compIdsMapper
try {
compIdsMapper = new Map()
} catch (error) {
compIdsMapper = new SimpleMap()
}
export function genCompid (key, isNeedCreate) {
if (!Current || !Current.current || !Current.current.$scope) return []
const prevId = compIdsMapper.get(key)
if (isNeedCreate) {
const id = genId()
compIdsMapper.set(key, id)
return [prevId, id]
} else {
const id = prevId || genId()
!prevId && compIdsMapper.set(key, id)
return [null, id]
}
}
if (res) return res
return null
}
let id = 0
function genId () {
return String(id++)
}
let compIdsMapper
try {
compIdsMapper = new Map()
} catch (error) {
compIdsMapper = new SimpleMap()
}
export function genCompid (key, isNeedCreate) {
if (!Current || !Current.current || !Current.current.$scope) return []
const prevId = compIdsMapper.get(key)
if (isNeedCreate) {
const id = genId()
compIdsMapper.set(key, id)
return [prevId, id]
} else {
const id = prevId || genId()
!prevId && compIdsMapper.set(key, id)
return [null, id]
}
}
if (res) return res
return null
}
let id = 0
function genId () {
return String(id++)
}
let compIdsMapper
try {
compIdsMapper = new Map()
} catch (error) {
compIdsMapper = new SimpleMap()
}
export function genCompid (key, isNeedCreate) {
if (!Current || !Current.current || !Current.current.$scope) return []
const prevId = compIdsMapper.get(key)
if (isNeedCreate) {
const id = genId()
compIdsMapper.set(key, id)
return [prevId, id]
} else {
const id = prevId || genId()
!prevId && compIdsMapper.set(key, id)
return [null, id]
}
}