Vue is a popular JavaScript framework that can be used to build modern web applications. Vue provides an easy way to develop rich interactive UIs, which makes it increasingly popular among many developers. Evernote is a well-known note-taking application that offers many features and has a very unique interface design. In this article, we will introduce how to use Vue to implement an Evernote-like page design.
- Create a Vue application
First, we need to create a new Vue application. You can use the Vue CLI to create a basic Vue application by simply running the following command in the terminal:
vue create my-app
This will create a new Vue application called "my-app".
- Install necessary dependencies
To achieve our goal, we need to install some necessary dependencies. We will install them using the following command:
npm install vue-router vuex vue-fontawesome bootstrap-vue
This will install the required dependencies including Vue-router, Vuex, FontAwesome and Bootstrap-Vue.
- Building Page Layout
Next, we will create a basic page layout that our application will use. We will create a left sidebar using a <navbar></navbar>
component and a <sidebar></sidebar>
component. This sidebar will be presented as a list containing notebooks and tags. On the right side, we will create a component called "NoteView" that will display the details of the note.
In the main component of our application we can include these components using the following code:
<template> <div> <navbar /> <div class="container-fluid mt-5"> <div class="row"> <sidebar /> <note-view /> </div> </div> </div> </template> <script> import Navbar from '@/components/Navbar.vue' import Sidebar from '@/components/Sidebar.vue' import NoteView from '@/components/NoteView.vue' export default { components: { Navbar, Sidebar, NoteView } } </script> <style> /* Visit https://bootstrap-vue.js.org/docs/ for BootstrapVue documentation and examples */ </style>
- Add routing and Vuex state management
Now, we need to add routing and Vuex state management to our application. We’ll use Vuex to store notebooks and tags, and use routing to jump to the notebook’s details page.
We first need to set some constants. In the src/store/index.js
file, we can add the following code:
export const SET_NOTEBOOKS = 'SET_NOTEBOOKS' export const SET_NOTES = 'SET_NOTES' export const SET_TAGS = 'SET_TAGS' export const SET_ACTIVE_NOTEBOOK = 'SET_ACTIVE_NOTEBOOK' export const SET_ACTIVE_NOTE = 'SET_ACTIVE_NOTE' export const ADD_NOTEBOOK = 'ADD_NOTEBOOK' export const ADD_NOTE = 'ADD_NOTE' export const ADD_TAG = 'ADD_TAG'
Next, we will define our Vuex states, and then create a storage file to manage these states. In the src/store/state.js
file, we can add the following code:
export default { notebooks: [], notes: [], tags: [], activeNotebook: null, activeNote: null }
Next, we need to set up some actions and mutations to update the notebooks and notes in the store. In the src/store/mutations.js
file, we can add the following code:
import { SET_NOTEBOOKS, SET_NOTES, SET_TAGS, SET_ACTIVE_NOTEBOOK, SET_ACTIVE_NOTE, ADD_NOTEBOOK, ADD_NOTE, ADD_TAG } from './index' export default { [SET_NOTEBOOKS](state, notebooks) { state.notebooks = notebooks }, [SET_NOTES](state, notes) { state.notes = notes }, [SET_TAGS](state, tags) { state.tags = tags }, [SET_ACTIVE_NOTEBOOK](state, notebook) { state.activeNotebook = notebook }, [SET_ACTIVE_NOTE](state, note) { state.activeNote = note }, [ADD_NOTEBOOK](state, notebook) { state.notebooks.push(notebook) }, [ADD_NOTE](state, note) { state.notes.push(note) }, [ADD_TAG](state, tag) { state.tags.push(tag) } }
In the src/store/actions.js
file, we can add The following code:
import axios from 'axios' import { SET_NOTEBOOKS, SET_NOTES, SET_TAGS, SET_ACTIVE_NOTEBOOK, SET_ACTIVE_NOTE, ADD_NOTEBOOK, ADD_NOTE, ADD_TAG } from './index' const api = 'https://my-json-server.typicode.com/abhinav1507/demo' export default { getNotebooks({ commit }) { axios.get(`${api}/notebooks`).then(response => { commit(SET_NOTEBOOKS, response.data) }) }, getNotes({ commit }) { axios.get(`${api}/notes`).then(response => { commit(SET_NOTES, response.data) }) }, getTags({ commit }) { axios.get(`${api}/tags`).then(response => { commit(SET_TAGS, response.data) }) }, setActiveNotebook({ commit }, notebook) { commit(SET_ACTIVE_NOTEBOOK, notebook) }, setActiveNote({ commit }, note) { commit(SET_ACTIVE_NOTE, note) }, addNotebook({ commit }, notebook) { axios.post(`${api}/notebooks`, notebook).then(response => { commit(ADD_NOTEBOOK, response.data) }) }, addNote({ commit }, note) { axios.post(`${api}/notes`, note).then(response => { commit(ADD_NOTE, response.data) }) }, addTag({ commit }, tag) { axios.post(`${api}/tags`, tag).then(response => { commit(ADD_TAG, response.data) }) } }
Next, in the src/router/index.js
file, we need to set up the routes to navigate within our application. We can add the following code:
import Vue from 'vue' import Vuex from 'vuex' import VueRouter from 'vue-router' import Home from '@/views/Home.vue' import Notebook from '@/views/Notebook.vue' Vue.use(VueRouter) Vue.use(Vuex) const routes = [ { path: '/', name: 'Home', component: Home }, { path: '/notebook/:id', name: 'Notebook', component: Notebook } ] const router = new VueRouter({ routes }) export default router
- Implementing the left sidebar
We will use the <sidebar></sidebar>
component to implement the left sidebar. In this component we will present notebooks and tabs along with the option to add notebooks or tabs. We'll also use icons from FontAwesome to differentiate these elements. You can add the following code in the src/components/Sidebar.vue
file:
<template> <div class="col-lg-3"> <div class="d-flex justify-content-between align-items-center mb-4"> <h5 id="Notebooks">Notebooks</h5> <b-button variant="primary" size="sm"> <font-awesome-icon :icon="['fas', 'plus']" /> Add </b-button> </div> <b-list-group> <b-list-group-item v-for="notebook in notebooks" :key="notebook.id"> <router-link :to="{ name: 'Notebook', params: { id: notebook.id}}"> <font-awesome-icon :icon="['fas', 'book-open']" /> {{ notebook.title }} </router-link> </b-list-group-item> </b-list-group> <div class="d-flex justify-content-between align-items-center mt-4"> <h5 id="Tags">Tags</h5> <b-button variant="primary" size="sm"> <font-awesome-icon :icon="['fas', 'plus']" /> Add </b-button> </div> <b-list-group> <b-list-group-item v-for="tag in tags" :key="tag.id"> <font-awesome-icon :icon="['fas', 'tag']" /> {{ tag.title }} </b-list-group-item> </b-list-group> </div> </template> <script> import { mapGetters } from 'vuex' export default { computed: { ...mapGetters({ notebooks: 'notebooks', tags: 'tags' }) } } </script>
- Implementing the notebook detail page
We will use a name Implement the notebook details page for the NoteView
component. In this component we will render the title and contents of the notebook. We'll also add a text box to the bottom of the notebook so users can add notes. You can add the following code in the src/components/NoteView.vue
file:
<template> <div class="col-lg-9"> <div class="d-flex justify-content-between align-items-center mb-4"> <router-link :to="{ name: 'Home'}" class="btn btn-secondary"> <font-awesome-icon :icon="['fas', 'arrow-left']" /> Back </router-link> <b-form-group label="Notebook" label-for="notebook"> <b-form-select v-model="activeNotebook" :options="notebooks" id="notebook" /> </b-form-group> </div> <div class="card"> <div class="card-header"> <input type="text" class="form-control" placeholder="Title"> </div> <div class="card-body"> <textarea class="form-control" placeholder="Note"></textarea> </div> </div> </div> </template> <script> import { mapGetters, mapActions } from 'vuex' export default { computed: { ...mapGetters({ notebooks: 'notebooks', activeNotebook: 'activeNotebook' }) }, methods: { ...mapActions({ setActiveNotebook: 'setActiveNotebook' }) }, created() { if (!this.activeNotebook && this.notebooks.length) { this.setActiveNotebook(this.notebooks[0]) } } } </script>
- Done
Now, we have the Vue application A page design imitating Evernote is implemented. We use components and routing to implement the left sidebar and note details page, and use Vuex state management to store notebooks, notes, and tags. We also used FontAwesome and Bootstrap-Vue to optimize our UI. More styles and functionality can be added and extended based on this Vue application.
The above is the detailed content of How to implement Evernote-like page design in Vue?. For more information, please follow other related articles on the PHP Chinese website!

The future trends and forecasts of Vue.js and React are: 1) Vue.js will be widely used in enterprise-level applications and have made breakthroughs in server-side rendering and static site generation; 2) React will innovate in server components and data acquisition, and further optimize the concurrency model.

Netflix's front-end technology stack is mainly based on React and Redux. 1.React is used to build high-performance single-page applications, and improves code reusability and maintenance through component development. 2. Redux is used for state management to ensure that state changes are predictable and traceable. 3. The toolchain includes Webpack, Babel, Jest and Enzyme to ensure code quality and performance. 4. Performance optimization is achieved through code segmentation, lazy loading and server-side rendering to improve user experience.

Vue.js is a progressive framework suitable for building highly interactive user interfaces. Its core functions include responsive systems, component development and routing management. 1) The responsive system realizes data monitoring through Object.defineProperty or Proxy, and automatically updates the interface. 2) Component development allows the interface to be split into reusable modules. 3) VueRouter supports single-page applications to improve user experience.

The main disadvantages of Vue.js include: 1. The ecosystem is relatively new, and third-party libraries and tools are not as rich as other frameworks; 2. The learning curve becomes steep in complex functions; 3. Community support and resources are not as extensive as React and Angular; 4. Performance problems may be encountered in large applications; 5. Version upgrades and compatibility challenges are greater.

Netflix uses React as its front-end framework. 1.React's component development and virtual DOM mechanism improve performance and development efficiency. 2. Use Webpack and Babel to optimize code construction and deployment. 3. Use code segmentation, server-side rendering and caching strategies for performance optimization.

Reasons for Vue.js' popularity include simplicity and easy learning, flexibility and high performance. 1) Its progressive framework design is suitable for beginners to learn step by step. 2) Component-based development improves code maintainability and team collaboration efficiency. 3) Responsive systems and virtual DOM improve rendering performance.

Vue.js is easier to use and has a smooth learning curve, which is suitable for beginners; React has a steeper learning curve, but has strong flexibility, which is suitable for experienced developers. 1.Vue.js is easy to get started with through simple data binding and progressive design. 2.React requires understanding of virtual DOM and JSX, but provides higher flexibility and performance advantages.

Vue.js is suitable for fast development and small projects, while React is more suitable for large and complex projects. 1.Vue.js is simple and easy to learn, suitable for rapid development and small projects. 2.React is powerful and suitable for large and complex projects. 3. The progressive features of Vue.js are suitable for gradually introducing functions. 4. React's componentized and virtual DOM performs well when dealing with complex UI and data-intensive applications.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SublimeText3 English version
Recommended: Win version, supports code prompts!

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft
