Browse Source
Update the `_init` and `_update` logic to partially support lifecycles. Add test cases for testing the lifecycle hooks and data update.dev
Hanks
7 years ago
committed by
Evan You
13 changed files with 229 additions and 37 deletions
@ -0,0 +1,39 @@ |
|||
<template recyclable="true"> |
|||
<div> |
|||
<text>{{number}}</text> |
|||
</div> |
|||
</template> |
|||
|
|||
<script> |
|||
module.exports = { |
|||
data () { |
|||
return { number: 0 } |
|||
}, |
|||
beforeCreate () { |
|||
try { __lifecycles.push('beforeCreate ' + this.number) } catch (e) {} |
|||
}, |
|||
created () { |
|||
try { __lifecycles.push('created ' + this.number) } catch (e) {} |
|||
this.number++ |
|||
}, |
|||
beforeMount () { |
|||
try { __lifecycles.push('beforeMount ' + this.number) } catch (e) {} |
|||
}, |
|||
mounted () { |
|||
try { __lifecycles.push('mounted ' + this.number) } catch (e) {} |
|||
this.number++ |
|||
}, |
|||
beforeUpdate () { |
|||
try { __lifecycles.push('beforeUpdate ' + this.number) } catch (e) {} |
|||
}, |
|||
updated () { |
|||
try { __lifecycles.push('updated ' + this.number) } catch (e) {} |
|||
}, |
|||
beforeDestroy () { |
|||
try { __lifecycles.push('beforeDestroy ' + this.number) } catch (e) {} |
|||
}, |
|||
destroyed () { |
|||
try { __lifecycles.push('destroyed ' + this.number) } catch (e) {} |
|||
} |
|||
} |
|||
</script> |
@ -0,0 +1,29 @@ |
|||
({ |
|||
type: 'recycle-list', |
|||
attr: { |
|||
append: 'tree', |
|||
listData: [ |
|||
{ type: 'X' }, |
|||
{ type: 'X' } |
|||
], |
|||
templateKey: 'type', |
|||
alias: 'item' |
|||
}, |
|||
children: [{ |
|||
type: 'cell-slot', |
|||
attr: { append: 'tree', templateType: 'X' }, |
|||
children: [{ |
|||
type: 'div', |
|||
attr: { |
|||
'@isComponentRoot': true, |
|||
'@componentProps': {} |
|||
}, |
|||
children: [{ |
|||
type: 'text', |
|||
attr: { |
|||
value: { '@binding': 'number' } |
|||
} |
|||
}] |
|||
}] |
|||
}] |
|||
}) |
@ -0,0 +1,21 @@ |
|||
<template> |
|||
<recycle-list :list-data="longList" template-key="type" alias="item"> |
|||
<cell-slot template-type="X"> |
|||
<lifecycle></lifecycle> |
|||
</cell-slot> |
|||
</recycle-list> |
|||
</template> |
|||
|
|||
<script> |
|||
// require('./lifecycle.vue') |
|||
module.exports = { |
|||
data () { |
|||
return { |
|||
longList: [ |
|||
{ type: 'X' }, |
|||
{ type: 'X' } |
|||
] |
|||
} |
|||
} |
|||
} |
|||
</script> |
Loading…
Reference in new issue