inject object throw component
| | |
| | | *.njsproj |
| | | *.sln |
| | | *.sw? |
| | | |
| | | package-lock.json |
| | |
| | | :topic-title="activeTopic && activeTopic.title" |
| | | :text="activeTopic && activeTopic.fullText" |
| | | ></active-element> |
| | | <knowledge-base :topics="topics" @select-topic="activateTopic"></knowledge-base> |
| | | <knowledge-base @select-topic="activateTopic"></knowledge-base> |
| | | </div> |
| | | </template> |
| | | |
| | |
| | | activeTopic: null, |
| | | }; |
| | | }, |
| | | provide:{ |
| | | topics: [ |
| | | { |
| | | id: 'basics', |
| | | title: 'The Basics', |
| | | description: 'Core Vue basics you have to know', |
| | | fullText: |
| | | 'Vue is a great framework and it has a couple of key concepts: Data binding, events, components and reactivity - that should tell you something!', |
| | | }, |
| | | { |
| | | id: 'components', |
| | | title: 'Components', |
| | | description: |
| | | 'Components are a core concept for building Vue UIs and apps', |
| | | fullText: |
| | | 'With components, you can split logic (and markup) into separate building blocks and then combine those building blocks (and re-use them) to build powerful user interfaces.', |
| | | }, |
| | | ], |
| | | }, |
| | | methods: { |
| | | activateTopic(topicId) { |
| | | this.activeTopic = this.topics.find((topic) => topic.id === topicId); |
| | |
| | | <template> |
| | | <section> |
| | | <h2>Select a Topic</h2> |
| | | <knowledge-grid :topics="topics" @select-topic="$emit('select-topic', $event)"></knowledge-grid> |
| | | <knowledge-grid @select-topic="$emit('select-topic', $event)"></knowledge-grid> |
| | | </section> |
| | | </template> |
| | | |
| | | <script> |
| | | export default { |
| | | props: ['topics'], |
| | | |
| | | emits: ['select-topic'], |
| | | }; |
| | | </script> |
| | |
| | | |
| | | <script> |
| | | export default { |
| | | props: ['topics'], |
| | | inject: ['topics'], |
| | | emits: ['select-topic'] |
| | | }; |
| | | </script> |