-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- [新增] 了解在beforeCreate生命周期里面, data和methods方法是否可以被调用
- Loading branch information
Showing
2 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/**Created by montage_fz on 2019-10-05**/ | ||
<template> | ||
<div class="Live"> | ||
生命周期测试 | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
name: 'Live', | ||
components: {}, | ||
data() { | ||
return { | ||
num: 1, | ||
}; | ||
}, | ||
beforeCreate() { | ||
// 当前生命周期无法获取methods里面的方法 | ||
try { | ||
this.init('我是beforeCreate生命周期'); | ||
} catch (e) { | ||
console.log('当前生命周期无法获取methods里面的方法'); | ||
} | ||
}, | ||
created() { | ||
try { | ||
this.init('我是created生命周期'); | ||
} catch (e) { | ||
console.log('当前生命周期无法获取methods里面的方法'); | ||
} | ||
}, | ||
computed: {}, | ||
methods: { | ||
init(value) { | ||
console.log(value, this.num); | ||
}, | ||
}, | ||
}; | ||
</script> | ||
|
||
<style scoped lang="less"> | ||
.Live { | ||
} | ||
</style> |