Vue前端练习

此练习项目只涉及前端,主要是vue和ElementUI框架的使用。(ElementUI官网:Element - The world's most popular Vue UI framework)

一、环境准备

  1. 安装idea

  2. 安装Node.js 一键式安装(不需要做任何配置) npm -v(也可用node多版本管理工具nvm进行管理和下载)

  3. 修改npm镜像源 npm config set registry https://registry.npmmirror.com

  4. 获取镜像源地址 npm config get registry

  5. 安装VUE Cli脚手架 npm install -g @vue/cli

  6. 验证Vue Cli安装是否成功 vue -V

     7.创建Vue Cli工程项目

        创建一个Vue-Workspace文件夹,用来存放vue项目。在此文件内,打开命令行。

      使用 vue create 命令即可创建VUE CLI工程,命令格式是:

vue create 工程名称

配置工作及如何在idea中打开,请参考以下教程 :

Vue-Cli(脚手架)安装及如何创建Vue-Cli项目-保姆级别教程,手把手教会你-CSDN博客

      8.工程结构

      8.1 App.vue:此vue文件是访问工程根路径时自动显示的组件(* .vue)

      8.2 views文件夹:以后开发的所有的页面(*.vue)基本上都是保存在此文件夹下

      8.3 router/index.js:路由配置文件,在里面配置客户端请求xxx地址时由xxx.vue页面显示

      8.4 main.js:工程的主JS文件,引入各个框架的代码写在此文件下

      8.5 package.json:修改端口号,修改框架版本在此配置文件中操作

      8.6 public文件夹:图片资源文件保存在此文件夹下

     9.引入ElementUI框架

       9.1终止vue启动,并执行npm install --save element-ui

       9.2在main.js中引入

             import ElementUI from 'element-ui';

             import 'element-ui/lib/theme-chalk/index.css';

             Vue.use(ElementUI);

main.js代码:

import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
Vue.use(ElementUI);Vue.config.productionTip = falsenew Vue({router,store,render: h => h(App)
}).$mount('#app')

二、具体实现及代码

项目结构如下:

index.js

import Vue from 'vue'
import VueRouter from 'vue-router'
import HomeView from '../views/HomeView.vue'Vue.use(VueRouter)const routes = [{path: '/',name: 'home',component: HomeView,children:[{path: '/reg',component: ()=>import('../views/RegView.vue')},{path: '/login',component: ()=>import('../views/LoginView.vue')},{path: '/index',component: ()=>import('../views/IndexView.vue')},{path: '/detail',component: ()=>import('../views/DetailView.vue')}]}]const router = new VueRouter({mode: 'history',base: process.env.BASE_URL,routes
})export default router

App.vue

<template><div id="app"><router-view/></div>
</template><style>
body {background-color: rgb(241, 242, 243);
}</style>

HomeView.vue

<template><div class="home"><el-container><!--页面头部--><el-header height="80px" style="background-color: white"><div style="width: 1200px;margin: 0 auto"><el-row :gutter="20"><el-col :span="6"><img src="/imgs/icon.png" width="200"></el-col><el-col :span="10"><el-menu mode="horizontal" active-text-color="orange"><el-menu-item index="1">首页</el-menu-item><el-menu-item index="2">食谱</el-menu-item><el-menu-item index="3">视频</el-menu-item><el-menu-item index="4">资讯</el-menu-item></el-menu><div class="line"></div></el-col><el-col :span="6"><el-input placeholder="请输入搜索的关键字" style="position: relative;top: 20px"><el-button slot="append" icon="el-icon-search"></el-button></el-input></el-col><el-col :span="2"><el-popoverplacement="top-start"title="欢迎来到烘焙坊!"width="200"trigger="hover"><i slot="reference" class="el-icon-user"style="font-size: 30px;position: relative;top: 20px"></i><el-button type="info" @click="reg()">注册</el-button><el-button type="warning" @click="login()">登录</el-button></el-popover></el-col></el-row></div></el-header><el-main id="el-main"><router-view/></el-main><!--页面页脚--><el-footer style="height:280px;background-color: black;padding: 50px"><div style="width: 1200px;color:#666;text-align:center;margin: 0 auto"><el-row><el-col :span="8"><img src="/imgs/icon.png" width="200"><p>教程灵感就看烘焙坊</p><p>烘焙行业网络社区平台</p><p>全国百城上千个职位等你来</p></el-col><el-col :span="8"><el-row id="footer_center"><el-col :span="8"><h3>关于我们</h3><p>烘焙学院</p><p>烘焙食谱</p><p>分类信息</p><p>招聘信息</p><p>社区交流</p></el-col><el-col :span="8"><h3>服务与支持</h3><p>联系我们</p><p>广告投放</p><p>用户协议</p><p>友情链接</p><p>在线反馈</p><p>我发投稿</p></el-col><el-col :span="8"><h3>底部导航</h3><p>Archiver</p><p>手机版</p><p>小黑屋</p></el-col></el-row></el-col><el-col :span="8"><p style="font-size: 60px;margin: 0"><span style="color: orange">烘焙</span>坊</p><p>烘焙行业网络社区平台</p></el-col></el-row></div></el-footer></el-container></div>
</template><script>export default {name: 'HomeView',methods: {reg() {/*location.href='/reg'   /!*这种跳转方法是页面整体刷新,影响页面的加载速度*!/*//*脚手架开发中使用这种跳转方式*/if (this.$route.path !== '/reg') {this.$router.push('/reg');}},login() {/*location.href='/login'*/if (this.$route.path !== '/login') {this.$router.push('/login');}}},
}
</script><style>
#footer_center p {margin: 0;
}#footer_center h3 {color: white;
}#el-main {margin: 0;padding: 0;
}
</style>

IndexView.vue

<template><div style="width: 1200px;margin: 10px auto"><!-- 轮播图 --><el-carousel height="350px"><el-carousel-item><img src="/imgs/banner1.jpg"></el-carousel-item><el-carousel-item><img src="/imgs/banner2.jpg"></el-carousel-item><el-carousel-item><img src="/imgs/banner3.jpg"></el-carousel-item></el-carousel><!-- 烘焙食谱导航条--><el-row style="background-color: white"><el-col :span="3"><p style="font-size: 28px;margin: 15px">烘焙食谱</p></el-col><el-col :span="21"><el-menu mode="horizontal" active-text-color="orange" default-active="1"><el-menu-item index="1">全部</el-menu-item><el-menu-item index="2">面包</el-menu-item><el-menu-item index="3">零食</el-menu-item><el-menu-item index="4">家常菜</el-menu-item></el-menu></el-col></el-row><!--烘焙食谱列表--><el-row :gutter="20"><el-col :span="6" v-for="item in recipeArr" style="margin: 10px 0"><el-card><a href="javascript:void(0)"><img :src="item.imgUrl" width="100%" height="145"><p style="height: 40px;">{{ item.title }}</p></a><el-row><el-col :span="4"><el-avatar :src="item.userImgUrl" size="small"></el-avatar></el-col><el-col :span="10">{{ item.nickName }}</el-col><el-col :span="10"><span style="float: right;font-size: 12px;color: #666">{{ item.categoryName }}</span></el-col></el-row></el-card></el-col></el-row><!--点击加载更多--><div style="text-align: center"><el-button>点击加载更多</el-button></div><!-- 烘焙视频导航条--><el-row style="background-color: white"><el-col :span="3"><p style="font-size: 28px;margin: 15px">烘焙视频</p></el-col><el-col :span="21"><el-menu mode="horizontal" active-text-color="orange" default-active="1"><el-menu-item index="1">面包教学</el-menu-item><el-menu-item index="2">零食鉴赏</el-menu-item><el-menu-item index="3">家常菜教程</el-menu-item></el-menu></el-col></el-row><!--烘焙视频列表--><el-row :gutter="20"><el-col :span="6" v-for="item in recipeArr" style="margin: 10px 0"><el-card><a href="javascript:void(0)"><img :src="item.imgUrl" width="100%" height="145"><p style="height: 40px;">{{ item.title }}</p></a><el-row><el-col :span="4"><el-avatar :src="item.userImgUrl" size="small"></el-avatar></el-col><el-col :span="10">{{ item.nickName }}</el-col><el-col :span="10"><span style="float: right;font-size: 12px;color: #666">{{ item.categoryName }}</span></el-col></el-row></el-card></el-col></el-row><!--点击加载更多--><div style="text-align: center"><el-button>点击加载更多视频</el-button></div><!-- 行业资讯导航条--><el-row style="background-color: white"><el-col :span="3"><p style="font-size: 28px;margin: 15px">行业资讯</p></el-col><el-col :span="21"><el-menu mode="horizontal" active-text-color="orange" default-active="1"><el-menu-item index="1">全部</el-menu-item><el-menu-item index="2">美食资讯</el-menu-item><el-menu-item index="3">店家资讯</el-menu-item></el-menu></el-col></el-row><!--行业资讯列表--><el-row :gutter="20"><el-col :span="6" v-for="item in recipeArr" style="margin: 10px 0"><el-card><a href="javascript:void(0)"><img :src="item.imgUrl" width="100%" height="145"><p style="height: 40px;">{{ item.title }}</p></a><el-row><el-col :span="4"><el-avatar :src="item.userImgUrl" size="small"></el-avatar></el-col><el-col :span="10">{{ item.nickName }}</el-col><el-col :span="10"><span style="float: right;font-size: 12px;color: #666">{{ item.categoryName }}</span></el-col></el-row></el-card></el-col></el-row><!--点击加载更多--><div style="text-align: center"><el-button>点击加载更多资讯</el-button></div></div>
</template><script>
export default {name: "IndexView",data() {return {recipeArr: [{"id": 27,"title": "家常面包","imgUrl": "imgs/a.jpg","categoryName": "面包","nickName": "汤姆","userImgUrl": "imgs/head.jpg"},{"id": 18,"title": "爆浆抹茶甜甜圈面包,自带幸福感的小甜甜","imgUrl": "imgs/b.jpg","categoryName": "家常菜","nickName": "汤姆","userImgUrl": "imgs/head.jpg"},{"id": 17,"title": "心形火龙果椰蓉面包,任谁都抗拒不了","imgUrl": "imgs/c.jpg","categoryName": "小食","nickName": "汤姆","userImgUrl": "imgs/head.jpg"},{"id": 16,"title": "蔓越莓绿豆糕,味道还不错值得一试!","imgUrl": "imgs/d.jpg","categoryName": "面包","nickName": "汤姆","userImgUrl": "imgs/head.jpg"},]}}
}
</script><style scoped>
a {text-decoration: none;color: #11192d;
}</style>

LoginView.vue

<template><div id="main_div"><el-card style="width: 500px;height: 300px;margin: 50px auto"><el-form label-width="80px" style="margin-top: 50px;width: 430px"><el-form-item label="用户名"><el-input placeholder="请输入用户名" v-model="user.username"></el-input></el-form-item><el-form-item label="密码"><el-input type="password" placeholder="请输入密码" v-model="user.password"></el-input></el-form-item><el-form-item style="text-align: center;"><el-button type="primary" style="position: relative;right: 30px">登录</el-button></el-form-item></el-form></el-card></div>
</template><script>
export default {name: "LoginView",data() {return {user: {username: "",password: ""}};}
}
</script><style scoped>#main_div {height: 500px;background-image: url('/public/imgs/loginbg.gif');background-position: center; /*设置背景图居中*/background-size: cover; /*设置为封面*/overflow: hidden; /*解决粘连问题*/
}</style>

RegView.vue

<template><div style="width: 1200px;margin: 20px auto"><el-row :gutter="20"><el-col :span="12"><el-card><img src="/imgs/reg.png" width="100%"></el-card></el-col><el-col :span="12"><el-form  label-width="80px" style="margin-top: 50px"><el-form-item><h1 style="font-size: 25px">立即注册 <a href="/login"style="font-size: 15px;color:#0aa1ed;text-decoration:none;float: right">已有账号?现在登录</a></h1></el-form-item><el-form-item label="用户名"><el-input placeholder="请输入用户名"></el-input></el-form-item><el-form-item label="密码"><el-input type="password" placeholder="请输入密码"></el-input></el-form-item><el-form-item label="昵称"><el-input placeholder="请输入昵称"></el-input></el-form-item><el-form-item style="text-align: center;"><el-button type="primary">注册</el-button></el-form-item></el-form></el-col></el-row></div>
</template><script>
export default {name: "RegView"
}
</script><style scoped></style>

DetailView.vue

<template><el-row gutter="20"><el-col span="18"><el-card><h2 style="color: orange;text-align: center">枣泥花式面包,好吃到爆!</h2><p style="font-size: 12px;color: #666;text-align: center">作者:汤姆 | 发布时间:2023/5/26 11:12:30 | 阅读次数:1</p><el-divider></el-divider><el-card style="font-size: 12px"><b style="color: #409EFF">摘要:</b>之前做了枣泥馅,配上花式面包,好吃到爆。 枣泥花式面包的用料 肉松面包面团</el-card><p style="height: 500px">文章内容</p></el-card><!--评论相关开始--><el-card><p>发一条友善的评论</p><el-divider></el-divider><el-row gutter="20"><el-col span="20"><el-input type="textarea" placeholder="说点儿啥..."></el-input></el-col><el-col span="2"><el-button>发布</el-button></el-col></el-row><!--评论列表开始--><el-row style="margin: 5px 0"><el-col span="2"><el-avatar src="imgs/head.jpg"></el-avatar></el-col><el-col span="20"><span style="color: orange;font-weight: bold">汤姆:</span><p style="margin:5px 0">开起来很好吃!</p><span style="color: #666;font-size: 12px">2023/5/26 15:52:30</span></el-col></el-row><el-row style="margin: 5px 0"><el-col span="2"><el-avatar src="imgs/head.jpg"></el-avatar></el-col><el-col span="20"><span style="color: orange;font-weight: bold">汤姆:</span><p style="margin:5px 0">开起来很好吃!</p><span style="color: #666;font-size: 12px">2023/5/26 15:52:30</span></el-col></el-row><el-row style="margin: 5px 0"><el-col span="2"><el-avatar src="imgs/head.jpg"></el-avatar></el-col><el-col span="20"><span style="color: orange;font-weight: bold">汤姆:</span><p style="margin:5px 0">开起来很好吃!</p><span style="color: #666;font-size: 12px">2023/5/26 15:52:30</span></el-col></el-row><!--评论列表结束--></el-card><!--评论相关结束--></el-col><el-col span="6"><el-card class="right-card" style="height: 240px;text-align: center;"><div style="background-image: url('/imgs/avarbg.jpg');height: 90px"></div><div style="position: relative;top: -45px"><img src="imgs/head.jpg"style="border-radius: 90px;border: 5px solid white;width: 90px;height: 90px"><p style="font-size: 20px;margin: 0;font-weight: bold">汤姆</p><i class="el-icon-edit">本文作者</i><br><i class="el-icon-time">2023/5/26 16:43:30</i></div></el-card><!--作者其它文章开始--><el-card style="margin:10px 0"><h3>作者其它文章</h3><el-divider></el-divider><!--文章列表开始--><el-row gutter="10" v-for="item in 4"><el-col span="10"><img src="imgs/a.jpg" width="100%" height="70px"></el-col><el-col span="14"><p style="margin: 0;height: 50px">枣泥面包好吃到爆!</p><i class="el-icon-time" style="color: #666">2023/6/30</i></el-col></el-row><!--文章列表结束--></el-card><!--作者其它文章结束--><!--热门文章开始--><el-card style="margin:10px 0"><h3>热门文章</h3><el-divider></el-divider><!--文章列表开始--><el-row gutter="10" v-for="item in 4"><el-col span="10"><img src="imgs/a.jpg" width="100%" height="70px"></el-col><el-col span="14"><p style="margin: 0;height: 50px">枣泥面包好吃到爆!</p><i class="el-icon-time" style="color: #666">2023/6/30</i></el-col></el-row><!--文章列表结束--></el-card><!--热门文章结束--></el-col></el-row></template><script>
export default {name: "DetailView"
}
</script><style scoped></style>

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/diannao/39720.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

mysql-sql-第十五周

学习目标&#xff1a; sql 学习内容&#xff1a; 41.查询没有学全所有课程的同学的信息 select *from students where students.stunm not in (select score.stunm from score group by score.stunm having count(score.counm) (select count(counm) from course)) 42.查询…

数据结构_线性表

线性表的定义和特点 线性表是具有相同特性的数据元素的一个有限序列 :线性起点/起始节点 :的直接前驱 :的直接后继 :线性终点/终端节点 n:元素总个数,表长 下标:是元素的序号,表示元素在表中的位置 n0时称为空表 线性表 由n(n>0)个数据元素(结点),组成的有限序列 将…

安卓模拟器如何修改ip地址

最近很多老铁玩游戏的&#xff0c;想多开模拟器一个窗口一个IP&#xff0c;若模拟器窗口开多了&#xff0c;IP一样会受到限制&#xff0c;那么怎么更换自己电脑手机模拟器IP地址呢&#xff0c;今天就教大家一个修改模拟器IP地址的方法&#xff01;废话不多说&#xff0c;直接上…

alibaba EasyExcel 简单导出数据到Excel

导入依赖 <dependency><groupId>com.alibaba</groupId><artifactId>easyexcel</artifactId><version>4.0.1</version> </dependency> 1、alibaba.excel.EasyExcel导出工具类 import com.alibaba.excel.EasyExcel; import …

探索哈希函数:数据完整性的守护者

引言 银行在处理数以百万计的交易时&#xff0c;如何确保每一笔交易都没有出错&#xff1f;快递公司如何跟踪成千上万的包裹&#xff0c;确保每个包裹在运输过程中没有丢失或被替换&#xff1f;医院和诊所为庞大的患者提供有效的医疗保健服务&#xff0c;如何确保每个患者的医疗…

假阳性和假阴性、真阳性和真阴性

在深度学习的分类问题中&#xff0c;真阳性、真阴性、假阳性和假阴性是评估模型性能的重要指标。它们的定义和计算如下&#xff1a; 真阳性&#xff08;True Positive, TP&#xff09;&#xff1a; 定义&#xff1a;模型预测为正类&#xff08;阳性&#xff09;&#xff0c;且实…

电梯修理升级,安装【电梯节能】能量回馈设备

电梯修理升级&#xff0c;安装【电梯节能】能量回馈设备 1、节能率评估 15%—45% 2、降低机房环境温度&#xff0c;改善电梯控制系统的运行环境&#xff1b; 3、延长电梯使用寿命&#xff1b; 4、机房可以不需要使用空调等散热设备的耗电&#xff0c;间接节省电能。 欢迎私询哦…

智能数字人系统的主要功能

智能数字人系统或虚拟数字人系统&#xff0c;是指利用人工智能技术构建的虚拟人物形象&#xff0c;能够与人进行自然交互的系统。数字人系统的主要功能包括以下几个方面。北京木奇移动技术有限公司&#xff0c;专业的软件外包开发公司&#xff0c;欢迎交流合作。 1. 语言理解与…

昇思25天学习打卡营第2天|初学入门

昇思25天学习打卡营第2天 文章目录 昇思25天学习打卡营第2天网络构建定义模型类模型层nn.Flattennn.Densenn.ReLUnn.SequentialCellnn.Softmax 模型参数 函数式自动微分函数与计算图微分函数与梯度计算Stop GradientAuxiliary data神经网络梯度计算 问题集合打卡记录 网络构建 …

华为DCN之:SDN和NFV

1. SDN概述 1.1 SDN的起源 SDN&#xff08;Software Defined Network&#xff09;即软件定义网络。是由斯坦福大学Clean Slate研究组提出的一种新型网络创新架构。其核心理念通过将网络设备控制平面与数据平面分离&#xff0c;从而实现了网络控制平面的集中控制&#xff0c;为…

移动网络捕获在数字化转型中的重要性

数字化转型重新定义了企业运营和与客户互动的方式。它为组织提供价值的方式带来了根本性的转变&#xff0c;使流程更易于访问、更高效、更具协作性和更安全。然而&#xff0c;跟上不断发展的数字环境可能是一项挑战&#xff0c;而未能接受数字化转型的企业则面临被淘汰的风险。…

【MindSpore学习打卡】应用实践-计算机视觉-ShuffleNet图像分类:从理论到实践

在当今的深度学习领域&#xff0c;卷积神经网络&#xff08;CNN&#xff09;已经成为图像分类任务的主流方法。然而&#xff0c;随着网络深度和复杂度的增加&#xff0c;计算资源的消耗也显著增加&#xff0c;特别是在移动设备和嵌入式系统中&#xff0c;这种资源限制尤为突出。…

25计算机考研,这些学校双非闭眼入,性价比超高!

计算机考研&#xff0c;好的双非院校也很多&#xff01; 对于一些二本准备考研的同学来说&#xff0c;没必要一直盯着985/211这些院校&#xff0c;竞争激烈不说&#xff0c;容易当陪跑&#xff0c;下面这些就是不错的双非院校&#xff1a; 燕山大学南京邮电大学南京信息工程大…

WPS-Word文档表格分页

一、问题描述 这种情况不好描述 就是像这种表格内容&#xff0c;但是会有离奇的分页的情况。这种情况以前的错误解决办法就是不断地调整表格的内容以及间隔显得很乱&#xff0c;于是今天去查了解决办法&#xff0c;现在学会了记录一下避免以后忘记了。 二、解决办法 首先记…

8.SQL注入-基于insert,update利用案例

SQL注入-基于insert/update利用案例 sql语句正常插入表中的数据 insert into member(username,pw,sex,phonenum,address,email) values(xiaoqiang,1111,1,2,3,4); select * from member;例如插入小强数据&#xff0c;如图所示&#xff1a; 采用or这个运算符&#xff0c;构造…

实测有效:Win11右键默认显示更多

Win11最大的变化之一莫过于右键菜单发生了变化&#xff0c;最大的问题是什么&#xff0c;是右键菜单很多时候需要点两次&#xff0c;实在是反人类 第一步 复制以下命令直接运行&#xff1a; reg.exe add "HKCU\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905ba…

python_zabbix

zabbix官网地址&#xff1a;19. API19. APIhttps://www.zabbix.com/documentation/4.2/zh/manual/api 每个版本可以有些差异&#xff0c;选择目前的版本在查看对于的api接口#token接口代码 import requests apiurl "http://zabbix地址/api_jsonrpc.php" data {&quo…

web的学习和开发

这个使同步和异步的区别 今天主要就是学了一些前端&#xff0c;搞了一些前端的页面&#xff0c;之后准备学一下后端。 我写的这个项目使百度贴吧&#xff0c;还没有写er图。 先看一下主界面是什么样子的。 这个是主界面&#xff0c;将来后面的主要功能点基本上全部是放在这个上…

推动能源绿色低碳发展,风机巡检进入国产超高清+AI时代

全球绿色低碳能源数字转型发展正在进入一个重要窗口期。风电作为一种清洁能源&#xff0c;在碳中和过程中扮演重要角色&#xff0c;但风电场运维却是一件十足的“苦差事”。 传统的风机叶片人工巡检方式主要依靠巡检人员利用高倍望远镜检查、高空绕行下降目测检查(蜘蛛人)、叶…

STM32——Modbus协议

一、Modbus协议简介&#xff1a; 1.modbus介绍&#xff1a; Modbus是一种串行通信协议&#xff0c;是Modicon公司&#xff08;现在的施耐德电气 Schneider Electric&#xff09;于1979年为使用可编程逻辑控制器&#xff08;PLC&#xff09;通信而发表。Modbus已经成为工业领域…