Last active
December 30, 2017 15:08
-
-
Save srph/665af67d03c3194e05e5db1a6c0b8ff1 to your computer and use it in GitHub Desktop.
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 characters
| <template> | |
| <div> | |
| <slot></slot> | |
| </div> | |
| </template> | |
| <script> | |
| export default { | |
| name: 'autocomplete', | |
| provide() { | |
| return { | |
| autocomplete: { | |
| setInput: (input) => { | |
| this.input = input | |
| } | |
| } | |
| } | |
| }, | |
| data() { | |
| return { | |
| value: '', | |
| input: null | |
| } | |
| } | |
| methods: { | |
| onInput() { | |
| // Use this.input here to do stuff | |
| } | |
| }, | |
| // Other properties... redacted for example purposes | |
| } | |
| </script> |
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 characters
| <template> | |
| <input v-bind="$props" v-on="$listeners" ref="input"> | |
| </template> | |
| <script> | |
| export default { | |
| name: 'autocomplete-input', | |
| inject: ['autocomplete'], | |
| mounted() { | |
| this.autocomplete.setInput(this.$refs.input) | |
| }, | |
| // Other properties... redacted for example purposes | |
| } | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment