Procházet zdrojové kódy

rename: init -> beforeCreate

Evan You před 10 roky
rodič
revize
8c86973198

+ 1 - 1
src/core/config.js

@@ -84,7 +84,7 @@ const config: Config = {
    * List of lifecycle hooks.
    */
   _lifecycleHooks: [
-    'init',
+    'beforeCreate',
     'created',
     'beforeMount',
     'mounted',

+ 1 - 1
src/core/instance/init.js

@@ -39,7 +39,7 @@ export function initMixin (Vue: Class<Component>) {
     vm._self = vm
     initLifecycle(vm)
     initEvents(vm)
-    callHook(vm, 'init')
+    callHook(vm, 'beforeCreate')
     initState(vm)
     callHook(vm, 'created')
     initRender(vm)

+ 2 - 2
test/unit/features/global-api/mixin.spec.js

@@ -22,12 +22,12 @@ describe('Global API: mixin', () => {
     const calls = []
     const Test = Vue.extend({
       name: 'test',
-      init () {
+      beforeCreate () {
         calls.push(this.$options.myOption + ' local')
       }
     })
     Vue.mixin({
-      init () {
+      beforeCreate () {
         calls.push(this.$options.myOption + ' global')
       }
     })

+ 2 - 2
test/unit/features/options/lifecycle.spec.js

@@ -6,13 +6,13 @@ describe('Options lifecyce hooks', () => {
     spy = jasmine.createSpy('hook')
   })
 
-  describe('init', () => {
+  describe('beforeCreate', () => {
     it('should allow modifying options', () => {
       const vm = new Vue({
         data: {
           a: 1
         },
-        init () {
+        beforeCreate () {
           spy()
           expect(this.a).toBeUndefined()
           this.$options.computed = {