Using the created
lifecycle hook to change the 'text' data property.
export default {
data() {
return {
text: 'initial text'
}
},
created() {
this.text = 'The component is now created';
}
}
Run Example »
The created
lifecycle hook is called after the component is initialized.
Because the component is initialized, we can access properties inside the component instance such as data
or computed
, but we cannot access component DOM elements because they are not created until the mounted
hook.
Vue Tutorial: Vue Lifecycle Hooks
Vue Tutorial: The 'created' Hook
Vue Reference: Vue 'beforeCreate' Lifecycle Hook
Vue Reference: Vue 'mounted' Lifecycle Hook
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!