02---前端框架搭建

news2024/9/22 11:38:56

1、创建项目

1.该有的nodejs 、vue都要安装上,我用的是vuecli3,所以可以使用可视化界面 来创建项目(更加直观),当然你也可以采用命令行的方式创建项目。

2.cmd命令行输入: vue ui

3.在打开的可视化页面中,开始创建一个vue项目脚手架,插件可以先不勾选,到时候用什么再下,这里我选择的版本是vue2.0,而不是新版的3(因为3是最新版的有很多功能还不太熟悉,很多组件下载也不一样),看个人习惯。

4.创建项目名vue的脚手架,用vscode打开这个项目(也可以用idea打开,不过我感觉前端用vscode,java代码用idea更清晰一点)

2、下载插件

  1. 下载element-ui
  • 在vscode打开的这个vue项目中,终端输入npm install element-ui --save

  • 等待安装

  • 下载好后,在main.js中配置依赖

    import Element from 'element-ui'
    import "element-ui/lib/theme-chalk/index.css"
    Vue.use(Element)
    
  • 这样就可以使用elementui这个组件了

  • 参考element官网:https://element.eleme.cn/#/zh-CN/component/installation

  1. 下载Axious
  • 在终端输入 npm install axios --save

  • 下载后同样在main.js中配置

    import axios from 'axios'
    Vue.prototype.$axios = axios 
    

  • 安装组件后,我们就可以通过 this.$axios.get () 来发起我们的请求了,和后端交互。

3、页面主体

直接在Home.vue里面修改

  1. Home.vue
<template>
   <el-container style="height: 100vh; border: 1px solid #eee">
  <el-aside :width="sideWidth+'px'" style="background-color: rgb(238, 241, 246);height: 100%;" >
    <el-menu :default-openeds="['1', '3']" style="min-height:100%;overflow-x:hidden" 
    background-color="rgb(48,65,86)"
    text-color="#fff"
    active-text-color="ffd04b"
    :collapse-transition="false"
    :collapse="isCollapse"
    class="el-menu-vertical-demo"
    >
    <div style="height:60px;line-height:60px;text-align:center">
      <img src="../assets/logo.png" alt="" style="width:20px;position:relative;top:5px;margin-right: 5px;">
      <b style="color:#ccc" v-show="logoTextShow">后台管理系统</b>

    </div>
     
      <el-submenu index="1">
        <template slot="title">
          <i class="el-icon-message"></i>
          <span slot="title">导航一</span>
        </template>
        <el-menu-item-group>
          <template slot="title">分组一</template>
          <el-menu-item index="1-1">选项1</el-menu-item>
          <el-menu-item index="1-2">选项2</el-menu-item>
        </el-menu-item-group>
        <el-menu-item-group title="分组2">
          <el-menu-item index="1-3">选项3</el-menu-item>
        </el-menu-item-group>
        <el-submenu index="1-4">
          <template slot="title">选项4</template>
          <el-menu-item index="1-4-1">选项4-1</el-menu-item>
        </el-submenu>
      </el-submenu>
      <el-submenu index="2">
        <template slot="title"><i class="el-icon-menu"></i>
          <span slot="title">导航二</span>
        </template>
        <el-menu-item-group>
          <template slot="title">分组一</template>
          <el-menu-item index="2-1">选项1</el-menu-item>
          <el-menu-item index="2-2">选项2</el-menu-item>
        </el-menu-item-group>
        <el-menu-item-group title="分组2">
          <el-menu-item index="2-3">选项3</el-menu-item>
        </el-menu-item-group>
        <el-submenu index="2-4">
          <template slot="title">选项4</template>
          <el-menu-item index="2-4-1">选项4-1</el-menu-item>
        </el-submenu>
      </el-submenu>
      <el-submenu index="3">
        <template slot="title"><i class="el-icon-setting"></i>
          <span slot="title">导航三</span>
        </template>
        <el-menu-item-group>
          <template slot="title">分组一</template>
          <el-menu-item index="3-1">选项1</el-menu-item>
          <el-menu-item index="3-2">选项2</el-menu-item>
        </el-menu-item-group>
        <el-menu-item-group title="分组2">
          <el-menu-item index="3-3">选项3</el-menu-item>
        </el-menu-item-group>
        <el-submenu index="3-4">
          <template slot="title">选项4</template>
          <el-menu-item index="3-4-1">选项4-1</el-menu-item>
        </el-submenu>
      </el-submenu>
    </el-menu>
  </el-aside>
  
  <el-container>
    <el-header style=" font-size: 12px;border-bottom: 1px solid #ccc;line-height:60px;display: flex;">
      <div style="flex:1;font-size:18px">
        <span :class="collapseBtnClass" style="cursor:pointer" @click="collapse"></span>
      </div>
      <el-dropdown style="width:80px;cursor:pointer" >
        <span>Truthfully</span><i class="el-icon-arrow-down" style="margin-left:2px"></i>
        <i class="el-icon-setting" style="margin-right: 15px"></i>
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item>个人信息</el-dropdown-item>
          <el-dropdown-item>退出</el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
    </el-header>
    
    <el-main>
      <el-table :data="tableData">
        <el-table-column prop="date" label="日期" width="140">
        </el-table-column>
        <el-table-column prop="name" label="姓名" width="120">
        </el-table-column>
        <el-table-column prop="address" label="地址">
        </el-table-column>
      </el-table>
    </el-main>
  </el-container>
</el-container>
</template>

<script>
export default {
  name:'HomeView',
  data() {
      const item = {
        date: '2016-05-02',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1518 弄'
      };
      return {
        tableData: Array(20).fill(item),
        isCollapse:false,
        sideWidth:200,
        collapseBtnClass:'el-icon-s-fold' ,
        isCollapse:false,
        sideWidth:200 ,
        logoTextShow:true
      }
    },
    methods:{
      collapse(){ //点击收缩按钮触发
        this.isCollapse=!this.isCollapse
        if(this.isCollapse){  //收缩
          this.sideWidth=64
          this.collapseBtnClass='el-icon-s-unfold'
          this.logoTextShow=false
        }else{  //展开
          this.sideWidth = 200 
          this.collapseBtnClass='el-icon-s-fold'
          this.logoTextShow=true 
        }

      }
    }
}
</script>
  1. 创建一个公共样式,去除边框等

global.css

*{
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.ml-5{
    margin-left: 5px;
}

.mr-5{
    margin-right: 5px;
}

.pd-10{
    padding:10px 0;
}
  1. main.js
import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import Element from 'element-ui'
import "element-ui/lib/theme-chalk/index.css"
import axios from 'axios'
import './assets/global.css'
import ElementUI from 'element-ui'
Vue.use(ElementUI,{size:"mini"});
Vue.prototype.$axios = axios 
Vue.config.productionTip = false

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')

  1. 运行,得到初步效果图
  • 在终端输入 npm run serve
  • 打开localhost:8080
  • 如图

初步首页页面

4、完善页面主体

  • 加入搜索框
  • 加入增删按钮
  • 删除多余的导航框
  1. 完整vue代码

Home.vue

<template>
   <el-container style="height: 100vh; border: 1px solid #eee">
  <el-aside :width="sideWidth+'px'" style="background-color: rgb(238, 241, 246);height: 100%;" >
    <el-menu :default-openeds="['1', '3']" style="min-height:100%;overflow-x:hidden" 
    background-color="rgb(48,65,86)"
    text-color="#fff"
    active-text-color="ffd04b"
    :collapse-transition="false"
    :collapse="isCollapse"
    class="el-menu-vertical-demo"
    >
    <div style="height:60px;line-height:60px;text-align:center">
      <img src="../assets/logo.png" alt="" style="width:20px;position:relative;top:5px;margin-right: 5px;">
      <b style="color:#ccc" v-show="logoTextShow">后台管理系统</b>

    </div>
     
      <el-submenu index="1">
        <template slot="title">
          <i class="el-icon-message"></i>
          <span slot="title">导航一</span>
        </template>
        <el-submenu index="1-4">
          <template slot="title">选项4</template>
          <el-menu-item index="1-4-1">选项4-1</el-menu-item>
        </el-submenu>
      </el-submenu>
      <el-submenu index="2">
        <template slot="title"><i class="el-icon-menu"></i>
          <span slot="title">导航二</span>
        </template>
        <el-submenu index="2-4">
          <template slot="title">选项4</template>
          <el-menu-item index="2-4-1">选项4-1</el-menu-item>
        </el-submenu>
      </el-submenu>
      <el-submenu index="3">
        <template slot="title"><i class="el-icon-setting"></i>
          <span slot="title">导航三</span>
        </template>
        <el-submenu index="3-4">
          <template slot="title">选项4</template>
          <el-menu-item index="3-4-1">选项4-1</el-menu-item>
        </el-submenu>
      </el-submenu>
    </el-menu>
  </el-aside>
  
  <el-container>
    <el-header style=" font-size: 12px;border-bottom: 1px solid #ccc;line-height:60px;display: flex;">
      <div style="flex:1;font-size:18px">
        <span :class="collapseBtnClass" style="cursor:pointer" @click="collapse"></span>
      </div>
      <el-dropdown style="width:80px;cursor:pointer" >
        <span>Truthfully</span><i class="el-icon-arrow-down" style="margin-left:2px"></i>
        <i class="el-icon-setting" style="margin-right: 15px"></i>
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item>个人信息</el-dropdown-item>
          <el-dropdown-item>退出</el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
    </el-header>
    
    <el-main>
      <div style="margin-bottom:30px">
        <el-breadcrumb separator="/">
        <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
        <el-breadcrumb-item><a href="/">用户管理</a></el-breadcrumb-item>
        </el-breadcrumb> 
      </div>
      <div style="padding:10px 0">
        <el-input style="width:200px" placeholder="请输入名称" suffix-icon="el-icon-search"></el-input>
        <el-input style="width:200px" placeholder="请输入邮箱" suffix-icon="el-icon-message" class="ml-5"></el-input>
        <el-input style="width:200px" placeholder="请输入地址" suffix-icon="el-icon-position" class="ml-5"></el-input>
        <el-button class="ml-5" type="primary">搜索</el-button>
      </div>

      <div style="margin:10px 0">
        <el-button type="primary">新增<i class="el-icon-circle-plus-outline"></i></el-button>
        <el-button type="danger">批量删除<i class="el-icon-remove-outline"></i></el-button>
        <el-button type="primary">导入<i class="el-icon-top"></i></el-button>
        <el-button type="primary">导出<i class="el-icon-bottom"></i></el-button>
      </div>






      <el-table :data="tableData" border stripe >
        <el-table-column prop="date" label="日期" width="140">
        </el-table-column>
        <el-table-column prop="name" label="姓名" width="120">
        </el-table-column>
        <el-table-column prop="address" label="地址">
        </el-table-column>
        <el-table-column label="操作">
          <template >
            <el-button type="success">编辑 <i class="el-icon-edit"></i></el-button>
            <el-button type="danger">删除<i class="el-icon-remove-outline"></i></el-button>
          </template>
        </el-table-column>
      </el-table>
      <div style="padding:10px 0">
        <el-pagination
          :page-sizes="[5, 10, 15, 20]"
          :page-size="10"
          layout="total, sizes, prev, pager, next, jumper"
          :total="400">
        </el-pagination>
      </div>
    </el-main>
  </el-container>
</el-container>
</template>

<script>
export default {
  name:'HomeView',
  data() {
      const item = {
        date: '2016-05-02',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1518 弄'
      };
      return {
        tableData: Array(20).fill(item),
        isCollapse:false,
        sideWidth:200,
        collapseBtnClass:'el-icon-s-fold' ,
        isCollapse:false,
        sideWidth:200 ,
        logoTextShow:true
      }
    },
    methods:{
      collapse(){ //点击收缩按钮触发
        this.isCollapse=!this.isCollapse
        if(this.isCollapse){  //收缩
          this.sideWidth=64
          this.collapseBtnClass='el-icon-s-unfold'
          this.logoTextShow=false
        }else{  //展开
          this.sideWidth = 200 
          this.collapseBtnClass='el-icon-s-fold'
          this.logoTextShow=true 
        }

      }
    }
}
</script>
  1. 运行,如图

完善主体页面

前端框架和主体页面搭建完成,后面就开始搭建后端框架

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

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

相关文章

基于asp.net193酒店客房预订网站系统-计算机毕业设计

项目介绍 本酒店系统使用asp.net技术制作,在前台为普通用户提供预定和查询等系统使用功能&#xff0c;在后台为酒店管理员提供对系统平台的管理功能。在前台为用户提供的操作功能包括以下内容&#xff1a;站内新闻、用户注册、酒店查看&#xff0c;留言板等功能。此系统为管理…

AMAIZINGIC晶焱科技:Wi-Fi 6E 路由器产品的ESD/EOS防护方案

AMAIZINGIC晶焱科技&#xff1a;Wi-Fi 6E 路由器产品的ESD/EOS防护方案 随着无线网路的发展&#xff0c;IEEE协会于2020年提出了最新的Wi-Fi 6E&#xff0c;此版本为Wi-Fi 6的延伸版本&#xff0c;除了Wi-Fi 6原先支援的2.4GHz及5GHz的频段外&#xff0c;新增了6GHz的频段&…

功能超级强大,Python 命令行解析工具 argparse很好用

在工作中&#xff0c;我们经常需要从命令行当中解析出指定的参数&#xff0c;而 Python 也提供了相应的标准库来做这件事情&#xff0c;比如 sys, optparse, getopt, argparse。这里面功能最强大的莫过于 argparse&#xff0c;下面就来看看它用法。 import argparse # 使用 a…

Java+SSM在线商城系统电商购物系统(含源码+论文+答辩PPT等)

项目功能简介: 该项目采用的技术实现如下 后台框架&#xff1a;Spring、SpringMVC、MyBatis UI界面&#xff1a;BootStrap、jQuery 、JSP 数据库&#xff1a;MySQL 系统分为前台订票和后台管理&#xff1a; 1.前台商城 商品分类展示、商品详情、商品推荐、购物车、下单、支付 客…

课题设计基于nodejs购票系统的设计与实现.zip(论文+源码+ppt文档+视频录制)

第 1 章 绪 论 3 1.1研究现状及存在问题 3 1.2主要工作 4 第 2 章 系统开发技术概述 5 2.1 B/S 架构模式与C/S 架构模式 5 2.2 nodejs框架模式 6 第 3 章 需求分析 7 3.1 系统情况概述 7 3.2 系统功能性需求分析 9 3.3 系统非功能性需求分析 9 3.4 系统用例图 10 第 4 章 系统设…

【JavaSE】文件读写

目录 一、文件 1、文件的概念 1.广义 2.狭义 二、路径 1、绝对路径 2、相对路径 1.进入下一级./ 2.回退上一级../ 三、Java里的文件基本操作----File类 1、说明 2、File类的基本操作 1.基本方法 ​2.创建与删除文件 3.创建目录 4.文件的重命名 四、文件的读写操…

信息安全技术

安全分析模型自动化调优 MLOps&#xff08;Machine Learning Operations&#xff09;是一种人工智能 的工程实践&#xff0c;是面向机器学习项目的研发运营管理体系 。旨在实现 ML 管道的操作、ML 模型的部署和管理标准化&#xff0c;支持ML 模型的发布、激活、监控、性能跟踪…

【Spring Cloud】Nacos命名空间Namespace的介绍与使用

本期目录1. Namespace介绍2. 创建Namespace3. 配置Namespace专栏精选文章1. Namespace介绍 Namespace 通常用来做环境隔离。例如开发环境 dev 、测试环境 test 和生产环境 pro 之间的服务/数据相互隔离&#xff0c;无法相互访问。 Nacos 中服务和数据存储的最外层都是 Namespa…

常用性能测试工具的比较

目录性能测试的重要性针对接口的性能测试性能测试基准接口性能测试的主要指标abenchjMeterKelude性能脚本各种监控工具参考总结性能测试的重要性 众所周知性能测试在软件测试中占有举足轻重的作用&#xff0c;尤其是对于互联网产品这种具有大用户量&#xff0c;大数据量&#…

Spring Boot学习篇(一)

Spring Boot学习篇(一) 1 Spring、SpringBoot、SpringCloud有什么区别&#xff1f; spring一般指Spring框架&#xff08;SpringFramework&#xff09;&#xff0c;它是一个开源、轻量级的Java应用开发框架。其核心是控制反转IOC和面向切面编程AOP。Spring提供了很多包括ORM、…

Kaggle 新赛 | GoDaddy 微型企业密度预测

文章目录一、比赛背景和目标1. 背景2. 比赛目标二、提交、时间线和奖项三、代码要求一、比赛背景和目标 1. 背景 美国政策领导人努力发展更具包容性和抗衰退能力的经济体。他们也意识到&#xff0c;随着科技的进步&#xff0c;创业从来没有像今天这样容易。无论是创造一个更合…

【阙值分割】粒子群算法自适应多阈值图像分割【含Matlab源码 1459期】

⛄一、粒子群算法自适应多阈值图像分割简介 理论知识参考&#xff1a;【基础教程】基于matlab图像处理图像分割【含Matlab源码 191期】 粒子群优化的多阈值图像自分割算法 ⛄二、部分源代码 clc;clear;close all; %% 输入图像&#xff1b; Imag imread(‘24063.jpg’);%29…

【算法】常见的排序算法(插入排序、希尔排序、选择排序、冒泡排序、快速排序、归并排序)

目录一.常见排序类型二.排序详解1.冒泡排序2.选择排序3.插入排序4.希尔排序5.快速排序6.归并排序一.常见排序类型 插入排序&#xff1a;插入排序、希尔排序选择排序&#xff1a;简单选择排序、堆排序交换排序&#xff1a;冒泡排序、快速排序归并排序基数排序(又叫桶排序)八万个…

Java项目:新闻推荐管理系统(java+SSM+JavaScript+Ajax+Mysql)

源码获取&#xff1a;俺的博客首页 "资源" 里下载&#xff01; 项目介绍 本项目新闻推荐管理系统&#xff1b; 前台: 登录、首页、全部新闻、系统特色、猜你喜欢、分类、评论 后台&#xff1a; &#xff08;1&#xff09;文件管理&#xff1a;文件列表。 &#x…

3.无重复字符的最长子串

原题&#xff1a;https://leetcode.cn/problems/longest-substring-without-repeating-characters/ 目录 题目描述 题解 代码实现 题目描述 给定一个字符串s&#xff0c;请你找出其中不含有重复字符的最长子串的长度。 示例 1&#xff1a; 输入&#xff1a;s "…

微型计算机技术及应用笔记

微型计算机概述 主机系统包括&#xff1a; CPU存储器输入输出接口总线CPU包括&#xff1a; 运算器&#xff08;ALU&#xff09;控制器&#xff08;CU&#xff09;寄存器组&#xff08;Register&#xff09;寄存器&#xff1a;通用寄存器、专用寄存器 控制器由指令寄存器、指令…

攻防世界——Web新手练习区

目录 view_source get_post robots ​backup cookie disabled_button simple_js xff_referer weak_auth command_execution simple_php view_source 知识点&#xff1a; 查看网页源代码的几种方式&#xff1a; 按F12键&#xff0c;点击elements可以查看源代码快捷…

《图解TCP/IP》阅读笔记(第六章 6.1、6.2)—— 传输层的作用、端口号

第六章 TCP与UDP TCP与UDP和赫赫威名&#xff0c;在此前几章已略有耳闻。 TCP提供可靠的通信传输&#xff0c;而UDP则常被用于让广播和细节控制交给应用的通信传输。 首先&#xff0c;我们先来回顾一下传输层的定义。 上一章中提到过&#xff0c;IP中有一个协议字段&#x…

猿如意|程序员的如意神器之【chat GPT】测评。

chat GPT测评1、使用感受2、功能展示3、期待优化地方3.1 猿如意网页版搜索功能3.2 chat GPT3.2.1 测试抢券才能体验3.2.2 聊天体验1、使用感受 首先&#xff0c;需要对猿如意进行点赞。 正如宣传语所说&#xff0c;猿如意&#xff0c;程序员的的如意兵器&#xff0c;这句话&am…

[附源码]Node.js计算机毕业设计个性化旅游线路推荐系统Express

项目运行 环境配置&#xff1a; Node.js最新版 Vscode Mysql5.7 HBuilderXNavicat11Vue。 项目技术&#xff1a; Express框架 Node.js Vue 等等组成&#xff0c;B/S模式 Vscode管理前后端分离等等。 环境需要 1.运行环境&#xff1a;最好是Nodejs最新版&#xff0c;我…