Home > Article > Web Front-end > How to use Vue to implement page design that imitates picture-taking photography?
With the continuous development of Internet technology, more and more people are participating in photography, and at the same time, more and more people are paying attention to photography works. In this context, Tuchong Photography has become a platform that has attracted much attention. The page design adopted by the Tuchong Photography website is very exquisite, making people fall in love with this platform at first sight. This article will introduce how to use the Vue framework to implement a page design that imitates picture insect photography.
Before starting, we need to prepare the following tools and environment:
npm install -g @vue/cli
After the installation is complete, we can use Vue CLI to quickly create a Vue project.
Open the command line and enter the following command:
vue create tuchong-photo
Among them, tuchong-photo is the name of the project, you can according to your own Named by preference.
Then, select Manually select features and select the required features as follows:
Next, follow the default options to complete the creation of the project step by step.
In the project root directory, open the command line and enter the following command to install the required plug-ins:
npm install -S vue-router vuex axios stylus stylus-loader
where , vue-router is used to manage page routing, vuex is used for state management, axios is used to send HTTP requests, stylus and stylus-loader are used to process style files.
Open the router directory under the src directory, create the index.js file, and enter the following code:
import Vue from 'vue' import Router from 'vue-router' import Home from '@/views/Home' Vue.use(Router) export default new Router({ routes: [ { path: '/', name: 'home', component: Home } ] })
In this code , we added a component named Home, and at the same time, we set this component as the default access path.
Create a views folder in the src directory, which contains files corresponding to the components defined in the routing settings, as well as other commonly used components. document. Here we create a new Home.vue component file and enter the following code in it:
<template> <div class="home"> <div class="banner"> <img class="banner-image" src="../assets/banner.jpg" alt="banner"> <div class="banner-title">图虫摄影</div> <div class="banner-subtitle">发现与分享你的世界</div> </div> </div> </template> <script> export default { name: 'Home' } </script> <style lang="stylus"> .home .banner position: relative height: 400px .banner-image width: 100% .banner-title position: absolute top: 50% left: 50% transform: translate(-50%, -50%) font-size: 3rem color: #fff text-shadow: 0 0 5px rgba(0, 0, 0, 0.5) .banner-subtitle position: absolute top: 50% left: 50% transform: translate(-50%, -50%) font-size: 1.5rem color: #fff text-shadow: 0 0 5px rgba(0, 0, 0, 0.5) </style>
Here, we use a component named Home, which contains a picture carousel and some display information. Styles are specified using stylus.
Enter npm run serve
on the command line to start the project, and then enter http:/ in the browser /localhost:8080
Visit the website.
On the Tuchong Photography website, there are many excellent functions, such as search, classification, tags, photographers' pages, etc. Next, we briefly introduce how to add these functions.
Search: Create a new Search.vue component to implement the search box and result display, and then add the corresponding path in the routing configuration. Before accessing this component, we need to call the search interface to obtain the search results.
Categories and tags: Create a new Category.vue component, which contains two display columns, one for classification and one for displaying tags. Then add the corresponding path in the routing configuration. In this page, we need to call the classification and labeling interface to obtain classification and labeling information.
Photographer's page: Create a new Photographer.vue component, which contains the photographer's picture display, personal information display and contact information. Then add the corresponding path in the routing configuration. Before accessing this component, we need to call the photographer interface to obtain photographer information and photo information.
In this article, we introduced how to use the Vue framework to implement a page design that imitates picture insect photography. We talked about creating projects, configuring routes, designing components, and how to add some extended functions. Through these contents, I believe readers can master the basic usage of the Vue framework and use it to implement their own projects.
The above is the detailed content of How to use Vue to implement page design that imitates picture-taking photography?. For more information, please follow other related articles on the PHP Chinese website!