-
-
Save FoxMalder/3a7d8cab97d9540be47c76d0cf9c1dd7 to your computer and use it in GitHub Desktop.
Revisions
-
zmts revised this gist
Feb 16, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ # Передать ивент из родителя в потомок (Vue.js) В потомке подписываемся на некое событие через `$parent.$on('some-event')`. В родителе емитим это событие. -
zmts revised this gist
Jan 22, 2018 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ # Vue.js При необходимости передать ивент из родителя в потомок. В потомке подписываемся на некое событие через `$parent.$on('some-event')`. В родителе емитим это событие. ``` -
zmts revised this gist
Jan 22, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ # При необходимости передать ивент из родителя в потомок В потомке подписываемся на некое событие `update` через `$parent` и `$on`. В родителе емитим это событие. ``` -
zmts created this gist
Jan 22, 2018 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,42 @@ # При необходимости передать ивент из родителя в потомок В потомке подписываемся на некое событие `update` через `$parent` и `$on` В родителе емитим это событие. ``` <div id="app"> <my-component></my-component> <button @click="click">Click</button> </div> ``` ``` var Child = { template: '<div>{{value}}</div>', data: function () { return { value: 0 }; }, methods: { setValue: function(value) { this.value = value; } }, created: function() { this.$parent.$on('update', this.setValue); } } new Vue({ el: '#app', components: { 'my-component': Child }, methods: { click: function() { this.$emit('update', 7); } } }) ```