网易严选商城前端实现-vue

简介: 网易严选商城前端实现-vue

项目展示


菜单栏展示


 

轮播图页面


 

新鲜好物页面


人气推荐


美食模块


核心代码

路由配置


1. import {
2.   createRouter,
3.   createWebHashHistory
4. } from 'vue-router'
5. import Layout from '@/views/Layout.vue'
6. import Home  from '@/views/Home/Home.vue'
7. const Login = () => import('@/views/Login.vue')
8. const Category = () => import('@/views/Category/Category.vue')
9. const Commodity = () => import('@/views/commodity/Commodity.vue')
10. const routes = [{
11. path: '/',
12. name: 'Layout',
13. component: Layout,
14. children:[
15.       {
16. path:'/',
17. component:Home
18.       },{
19. path:'/category/:id',
20. component:Category
21.       },{
22. path:'/commodity',
23. name: 'commodity',
24. component:Commodity
25.       }
26.     ]
27.   }, {
28. path: '/login',
29. component: Login
30.   }
31. 
32. ]
33. 
34. const router = createRouter({
35. // Hash模式
36. history: createWebHashHistory(),
37.   routes
38. })
39. 
40. export default router

主页面


1. <template>
2. <div class="home w">
3. <!-- 轮播图 -->
4. <HomeBanner/>
5. 
6. <!-- 新鲜好物 -->
7. <HomeNew />
8. <!-- 人气推荐 -->
9. <HomeHot />
10. <!-- 产品区块 -->
11. <HomeProduct />
12. 
13. </div>
14. </template>
15. 
16. <script>
17. import HomeBanner from './HomeBanner.vue'
18. import HomeNew from './HomeNew.vue'
19. import HomeHot from './HomeHot.vue'
20. import HomeProduct from './HomeProduct.vue'
21. export default {
22. components:{
23. HomeBanner,
24. HomeNew,
25. HomeHot,
26. HomeProduct
27.     }
28. };
29. </script>
30. 
31. <style lang="less" scoped>
32. </style>

数据层展示


1. const express = require('express');
2. // 引入轮播图数据
3. const bannerData=require('../data/banner.json')
4. const hotData=require('../data/hot.json') //人气推荐
5. const productData =require('../data/product.json') //产品区块
6. 
7. const router = express.Router();
8. 
9. 
10. // 测试接口
11. router.get('/test', (req, res) => {
12.     res.send('测试成功');
13. })
14. 
15. /**
16.  * 首页轮播图
17.  */
18. router.get('/home/banner',(req,res)=>{
19.     res.send(bannerData)
20. })
21. 
22. /**
23.  * 首页-人气推荐
24.  */
25.  router.get('/home/hot',(req,res)=>{
26.     res.send(hotData)
27. })
28. 
29. 
30. /**
31.  * 首页-产品区块
32.  */
33.  router.get('/home/product',(req,res)=>{
34.     res.send(productData)
35. })
36. 
37. module.exports = router;

跨域请求


1. const path = require('path');
2. 
3. const {
4.     defineConfig
5. } = require('@vue/cli-service')
6. module.exports = defineConfig({
7. transpileDependencies: true,
8. 
9. pluginOptions: {
10. 'style-resources-loader': {
11. preProcessor: 'less',
12. patterns: [
13.                 path.join(__dirname, './src/assets/styles/variables.less'),
14.                 path.join(__dirname, './src/assets/styles/mixins.less')
15.             ]
16.         }
17.     },
18. //跨域请求
19. devServer: {
20. proxy: {
21. '/api': {
22. target: 'http://you.163.com', //网易新闻接口
23. ws: true,
24. changeOrigin: true,
25. pathRewrite: { //重写路径
26. '^/api': ''
27.                 }
28.             },
29. '/foo': {
30. target: 'http://localhost:7788', //本地接口
31. ws: true,
32. changeOrigin: true,
33. pathRewrite: { //重写路径
34. '^/foo': ''
35.                 }
36.             }
37.         },
38.     }
39. })
目录
相关文章
|
2月前
|
JavaScript 前端开发
vue前端下载,实现点击按钮弹出本地窗口,选择自定义保存路径
这个不用代码实现(网上也找不到方法可以调出另存为窗口),更改浏览器设置就可以,否则,现在的浏览器都是默认直接保存到下载路径中
69 3
|
28天前
|
前端开发 应用服务中间件 nginx
Nginx配置详解Docker部署Nginx使用Nginx部署vue前端项目
Nginx配置详解Docker部署Nginx使用Nginx部署vue前端项目
110 0
|
7天前
|
缓存 安全 JavaScript
前端安全:Vue应用中防范XSS和CSRF攻击
【4月更文挑战第23天】本文探讨了在Vue应用中防范XSS和CSRF攻击的重要性。XSS攻击通过注入恶意脚本威胁用户数据,而CSRF则利用用户身份发起非授权请求。防范措施包括:对输入内容转义、使用CSP、选择安全的库;采用Anti-CSRF令牌、同源策略和POST请求对抗CSRF;并实施代码审查、更新依赖及教育团队成员。通过这些实践,可提升Vue应用的安全性,抵御潜在攻击。
|
1天前
|
JSON JavaScript 前端开发
前端框架vue的样式操作,以及vue提供的属性功能应用实战
前端框架vue的样式操作,以及vue提供的属性功能应用实战
|
1天前
|
JavaScript 前端开发 数据安全/隐私保护
优秀的前端框架vue,原理剖析与实战技巧总结【干货满满】(二)
优秀的前端框架vue,原理剖析与实战技巧总结【干货满满】(二)
|
1天前
|
JavaScript 前端开发 Python
优秀的前端框架vue,原理剖析与实战技巧总结【干货满满】(一)
优秀的前端框架vue,原理剖析与实战技巧总结【干货满满】(一)
|
1天前
|
开发框架 缓存 前端开发
|
11天前
|
前端开发 JavaScript
vue 前端参值后端接收的几种方式
vue 前端参值后端接收的几种方式
15 0
|
11天前
|
NoSQL JavaScript 前端开发
报错场景:ant design vue前端登录时,输入的验证码是对的,但是一直提上验证码错误,登录不进去 报错信息(Error in execution; nested exception)
报错场景:ant design vue前端登录时,输入的验证码是对的,但是一直提上验证码错误,登录不进去 报错信息(Error in execution; nested exception)
18 0
|
14天前
|
前端开发
Vue+ElementUI前端添加展开收起搜索框按钮
Vue+ElementUI前端添加展开收起搜索框按钮
17 0