Vue.js Assignment– 1
Vue.js Basics
Basic Questions
- Create a Vue component that demonstrates how a reactive object updates the DOM automatically.
- Use ref() and reactive() to track primitive and object state changes.
- Build a counter app and explain how Vue’s reactivity system handles updates.
- Show the difference between using ref() and reactive() for arrays.
- Demonstrate how Vue batches DOM updates in the rendering cycle.
- Create a component that uses watch to track a single reactive property.
- Create a component that uses watchEffect for auto-tracking dependencies.
- Build a simple app showing Virtual DOM updates when toggling between two components.
- Use the v-once directive to render static content and verify it doesn’t re-render.
- Use the v-pre directive to display raw template syntax instead of binding it.
- Create a custom directive that changes text color when applied to an element.
- Build a custom directive that adds a hover effect to buttons.
- Write a component using Mixins for reusing logic across two components.
- Refactor the same logic using Composition API with setup().
- Compare Mixins and Composition API in code by building a small form validator.
- Create a form where one field re-renders and another does not, using reactivity APIs.
- Use toRefs() to preserve reactivity when destructuring reactive state.
- Write a small demo to showcase the lifecycle of Vue rendering (beforeMount, mounted, updated).
- Create a nested component that shows how Virtual DOM diffing optimizes re-renders.
- Write a note explaining why Virtual DOM is faster than direct DOM manipulation.
Intermediate Questions
- Create a reactive Todo list using reactive() and show how Vue tracks array mutations.
- Build a component that uses a deep watcher to track nested object changes.
- Use markRaw() to exclude a specific object from reactivity and explain the impact.
- Create a component that uses shallowReactive() and demonstrate its limitations.
- Compare shallowRef() vs ref() in a simple list rendering example.
- Create a custom directive v-permission that conditionally renders buttons based on a user role.
- Build a custom directive v-focus to auto-focus input fields.
- Implement a debounce directive that delays user input handling in a search bar.
- Create a small example showing the Virtual DOM patching process with dynamic elements.
- Demonstrate how Vue reuses elements with the key attribute in Virtual DOM rendering.
- Implement a shared logic for input validation using Mixins.
- Refactor the above to use Composition API with reusable functions (useValidation).
- Use the provide and inject APIs to share reactive state across deeply nested components.
- Optimize a component with computed() properties instead of recalculating values in methods.
- Create a reactive chart where only updated data points re-render.
- Implement customRef() to create a reactive input field with custom logic.
- Show an example where watch is more suitable than computed.
- Profile a Vue app with Chrome DevTools and identify unnecessary re-renders.
- Use the v-memo directive (Vue 3.2+) to skip re-renders of static subtrees.
- Document a scenario where using Composition API significantly improves code organization vs Mixins.
Advanced Questions
- Build a real-time dashboard app using reactivity APIs (ref, computed, watchEffect).
- Implement a global custom directive for lazy-loading images.
- Create a Virtual DOM demo app comparing raw DOM manipulation vs Vue reactivity performance.
- Build a directive that automatically logs when an element is inserted or removed from the DOM.
- Use Mixins in a medium project and demonstrate name-collision issues.
- Refactor the project using Composition API to solve those issues.
- Implement effectScope() to manage and dispose reactivity scopes in a complex app.
- Create a performance benchmark comparing reactive vs shallowReactive for large data sets.
- Build a reusable custom hook (e.g., useDarkMode) with Composition API and reactive state.
- Final Hands-on Project:
- Build a small Vue app (e.g., Stock Tracker)
- Use reactivity APIs for state management
- Optimize rendering with Virtual DOM strategies
- Add custom directives for interactivity
- Compare Mixins vs Composition API for shared logic
- Apply performance tuning with markRaw, shallowRef, and v-memo