当前位置: 首页 > news >正文

vue(32) : win10创建vue2基础前端框架

  • vue2
  • element-ui
  • axios

1.创建vue2项目

开发工具为HBuilderX 3.7.3

1.1.新建项目

1.2.普通项目-vue项目(2.6.10)

等待创建项目

2.安装element-ui组件

2.1右键左下角开始图标

 2.2.cd进入项目目录,执行安装element-ui

npm i element-ui -S

 

2.3.main.js引入配置

import {Pagination,Dialog,Autocomplete,Dropdown,DropdownMenu,DropdownItem,Menu,Submenu,MenuItem,MenuItemGroup,Input,InputNumber,Radio,RadioGroup,RadioButton,Checkbox,CheckboxButton,CheckboxGroup,Switch,Select,Option,OptionGroup,Button,ButtonGroup,Table,TableColumn,DatePicker,TimeSelect,TimePicker,Popover,Tooltip,Breadcrumb,BreadcrumbItem,Form,FormItem,Tabs,TabPane,Tag,Tree,Alert,Slider,Icon,Row,Col,Upload,Progress,Spinner,Badge,Card,Rate,Steps,Step,Carousel,CarouselItem,Collapse,CollapseItem,Cascader,ColorPicker,Transfer,Container,Header,Aside,Main,Footer,Timeline,TimelineItem,Link,Divider,Image,Calendar,Backtop,PageHeader,CascaderPanel,Loading,MessageBox,Message,Notification
} from 'element-ui';Vue.use(Pagination);
Vue.use(Dialog);
Vue.use(Autocomplete);
Vue.use(Dropdown);
Vue.use(DropdownMenu);
Vue.use(DropdownItem);
Vue.use(Menu);
Vue.use(Submenu);
Vue.use(MenuItem);
Vue.use(MenuItemGroup);
Vue.use(Input);
Vue.use(InputNumber);
Vue.use(Radio);
Vue.use(RadioGroup);
Vue.use(RadioButton);
Vue.use(Checkbox);
Vue.use(CheckboxButton);
Vue.use(CheckboxGroup);
Vue.use(Switch);
Vue.use(Select);
Vue.use(Option);
Vue.use(OptionGroup);
Vue.use(Button);
Vue.use(ButtonGroup);
Vue.use(Table);
Vue.use(TableColumn);
Vue.use(DatePicker);
Vue.use(TimeSelect);
Vue.use(TimePicker);
Vue.use(Popover);
Vue.use(Tooltip);
Vue.use(Breadcrumb);
Vue.use(BreadcrumbItem);
Vue.use(Form);
Vue.use(FormItem);
Vue.use(Tabs);
Vue.use(TabPane);
Vue.use(Tag);
Vue.use(Tree);
Vue.use(Alert);
Vue.use(Slider);
Vue.use(Icon);
Vue.use(Row);
Vue.use(Col);
Vue.use(Upload);
Vue.use(Progress);
Vue.use(Spinner);
Vue.use(Badge);
Vue.use(Card);
Vue.use(Rate);
Vue.use(Steps);
Vue.use(Step);
Vue.use(Carousel);
Vue.use(CarouselItem);
Vue.use(Collapse);
Vue.use(CollapseItem);
Vue.use(Cascader);
Vue.use(ColorPicker);
Vue.use(Transfer);
Vue.use(Container);
Vue.use(Header);
Vue.use(Aside);
Vue.use(Main);
Vue.use(Footer);
Vue.use(Timeline);
Vue.use(TimelineItem);
Vue.use(Link);
Vue.use(Divider);
Vue.use(Image);
Vue.use(Calendar);
Vue.use(Backtop);
Vue.use(PageHeader);
Vue.use(CascaderPanel);Vue.use(Loading.directive);import axios from 'axios';Vue.prototype.$loading = Loading.service;
Vue.prototype.$msgbox = MessageBox;
Vue.prototype.$alert = MessageBox.alert;
Vue.prototype.$confirm = MessageBox.confirm;
Vue.prototype.$prompt = MessageBox.prompt;
Vue.prototype.$notify = Notification;
Vue.prototype.$message = Message;
import 'element-ui/lib/theme-chalk/index.css';

3.安装axios

3.1.npm安装axios

npm install --save axios

3.2.项目根目录创建[vue.config.js]文件, 内容如下

'use strict'
const path = require('path')function resolve(dir) {return path.join(__dirname, dir)
}const port = process.env.port || process.env.npm_config_port || 9527 // dev port
const name =  '测试' // page title// All configuration item explanations can be find in https://cli.vuejs.org/config/
module.exports = {/*** You will need to set publicPath if you plan to deploy your site under a sub path,* for example GitHub Pages. If you plan to deploy your site to https://foo.github.io/bar/,* then publicPath should be set to "/bar/".* In most cases please use '/' !!!* Detail: https://cli.vuejs.org/config/#publicpath*/publicPath: '/',outputDir: 'dist',assetsDir: 'static',lintOnSave: process.env.NODE_ENV === 'development',productionSourceMap: false,devServer: {port: port,open: true,overlay: {warnings: false,errors: true},proxy: {// 代理test开头的uri'/test': {target: 'http://192.168.1.1:8080', // 后端地址// target: 'localhost:8080/manage', // 原始地址changeOrigin: true, // 开启代理,在本地创建一个虚拟服务端pathRewrite: {'^/test': '/test'}}}//before: require('./mock/mock-server.js')},configureWebpack: {// provide the app's title in webpack's name field, so that// it can be accessed in index.html to inject the correct title.name: name,resolve: {alias: {'@': resolve('src')}}},chainWebpack(config) {// it can improve the speed of the first screen, it is recommended to turn on preload// it can improve the speed of the first screen, it is recommended to turn on preloadconfig.plugin('preload').tap(() => [{rel: 'preload',// to ignore runtime.js// https://github.com/vuejs/vue-cli/blob/dev/packages/@vue/cli-service/lib/config/app.js#L171fileBlacklist: [/\.map$/, /hot-update\.js$/, /runtime\..*\.js$/],include: 'initial'}])// when there are many pages, it will cause too many meaningless requestsconfig.plugins.delete('prefetch')// set svg-sprite-loaderconfig.module.rule('svg').exclude.add(resolve('src/icons')).end()config.module.rule('icons').test(/\.svg$/).include.add(resolve('src/icons')).end().use('svg-sprite-loader').loader('svg-sprite-loader').options({symbolId: 'icon-[name]'}).end()config.when(process.env.NODE_ENV !== 'development',config => {config.plugin('ScriptExtHtmlWebpackPlugin').after('html').use('script-ext-html-webpack-plugin', [{// `runtime` must same as runtimeChunk name. default is `runtime`inline: /runtime\..*\.js$/}]).end()config.optimization.splitChunks({chunks: 'all',cacheGroups: {libs: {name: 'chunk-libs',test: /[\\/]node_modules[\\/]/,priority: 10,chunks: 'initial' // only package third parties that are initially dependent},elementUI: {name: 'chunk-elementUI', // split elementUI into a single packagepriority: 20, // the weight needs to be larger than libs and app or it will be packaged into libs or apptest: /[\\/]node_modules[\\/]_?element-ui(.*)/ // in order to adapt to cnpm},commons: {name: 'chunk-commons',test: resolve('src/components'), // can customize your rulesminChunks: 3, //  minimum common numberpriority: 5,reuseExistingChunk: true}}})// https:// webpack.js.org/configuration/optimization/#optimizationruntimechunkconfig.optimization.runtimeChunk('single')})}
}

代理后端配置如下, 三个test改成相同的uri前缀即可, uri该签注会代理到后端

proxy: {
      // 代理test开头的uri
      '/test': {
        target: 'http://192.168.1.1:8080', // 后端地址
        changeOrigin: true, // 开启代理,在本地创建一个虚拟服务端
        pathRewrite: {
          '^/test': '/test'
        }
      }
    }

 3.3.src下创建util目录, util文件夹下创建request.js, 内容如下

const res = response.data

这个需要根据后端接口格式修改

/*引入axios*/
import axios from 'axios'
import { MessageBox, Message } from 'element-ui'const request = axios.create({baseURL: '', // 基础路径,将统一的部分全部封装withCredentials: true // 表示请求可以携带cookie
})axios.defaults.headers['Content-Type'] = 'application/x-www-form-urlencoded'// response interceptor
request.interceptors.response.use(/*** If you want to get http information such as headers or status* Please return  response => response*//*** Determine the request status by custom code* Here is just an example* You can also judge the status by HTTP Status Code*/response => {const res = response.data// if the custom code is not 20000, it is judged as an error.if (res.code !== '0') {Message({message: res.message || 'Error',type: 'error',duration: 3 * 1000})// return Promise.reject(new Error(res.message || 'Error'))return null} else {return res}},error => {console.log('err' + error) // for debugMessage({message: error.message,type: 'error',duration: 5 * 1000})return Promise.reject(error)}
)//前端采用export.default,在写后端代码时用module.export
export default request

4.创建测试调用http

4.1.src下创建api目录, api下创建test.js, 内容如下

import request from '@/util/request'export function add(data) {return request({url: '/my-boke',headers: { 'Content-Type': 'application/json' },method: 'post',data})
}export function update(data) {return request({url: '/my-boke',headers: { 'Content-Type': 'application/json' },method: 'put',data})
}export function del(data) {return request({url: '/my-boke',method: 'delete',params: data})
}export function env() {return request({url: '/fsa/env',method: 'get'})
}

4.2. vue.js调用http

<template></template><script>import {add,update,del,env} from '@/api/fsa'export default {name: 'app',data() {return {}},created() {this.t1()},methods: {t1() {env().then(response => {console.log(response)})}}}
</script><style>#app {font-family: 'Avenir', Helvetica, Arial, sans-serif;-webkit-font-smoothing: antialiased;-moz-osx-font-smoothing: grayscale;text-align: center;color: #2c3e50;margin-top: 60px;}
</style>

5.启动

npm run serve

6.编译

报错, 待解决

相关文章:

vue(32) : win10创建vue2基础前端框架

vue2element-uiaxios 1.创建vue2项目 开发工具为HBuilderX 3.7.3 1.1.新建项目 1.2.普通项目-vue项目(2.6.10) 等待创建项目 2.安装element-ui组件 2.1右键左下角开始图标 2.2.cd进入项目目录,执行安装element-ui npm i element-ui -S 2.3.main.js引入配置 import {Paginat…...

如何制作一款资源网站app

简介 平时生活学习中我们会经常登录各种网站&#xff0c;比如看电影&#xff0c;看视频学习&#xff0c;找资料等等。有时想找到一个靠谱的网站&#xff0c;花了很长时间也找不到。我自己收集了很多好的网站&#xff0c;主要是找资源的&#xff0c;然后我做了一个导航app软件&…...

解决在Win7下运行一些老游戏花屏或色彩异常问题的方法

有一些喜欢回顾经典老游戏的玩家们&#xff0c;在目前最新的windows7的操作系统下&#xff0c;运行某些游戏会出现花屏&#xff0c;问题的原因是因为win7对这些游戏的DirectDraw不兼容&#xff0c;一种方法是改游戏配置文件&#xff0c;把游戏色彩8bit改成16bit&#xff0c;当然…...

使用vue3+vite+elctron构建小项目介绍Electron进程间通信

进程间通信 (IPC) 是在 Electron 中构建功能丰富的桌面应用程序的关键部分之一。 由于主进程和渲染器进程在 Electron 的进程模型具有不同的职责&#xff0c;因此 IPC 是执行许多常见任务的唯一方法&#xff0c;例如从 UI 调用原生 API 或从原生菜单触发 Web 内容的更改。 在 …...

家政APP开发服务同城预约维修接单管理系统软件小程序

家政服务小程序是一个基于移动端的家政服务平台&#xff0c;为用户提供方便快捷的家政服务。以下是小程序的主要功能&#xff1a; 1. 家政服务内容展示&#xff1a;商家可以在小程序中展示各种家政服务项目&#xff0c;如清洁、保洁、保姆、月嫂、钟点工等。用户可以浏览服务信…...

NOIP2023模拟8联测29 C. 蛋糕

NOIP2023模拟8联测29 C. 蛋糕 文章目录 NOIP2023模拟8联测29 C. 蛋糕题目大意思路code 题目大意 你现在得到了一个二维蛋糕&#xff0c;它从左到右可以分成 n n n 列&#xff0c;每列高为 a i a_i ai​ 。对于每一列&#xff0c;又可以从下到上分为 a i a_i ai​ 块&#x…...

echarts的图表立体感——实现立体柱状图和立体饼图的详细教程

&#x1f602;博主&#xff1a;小猫娃来啦 &#x1f602;文章核心&#xff1a;使用echarts实现立体柱状图和立体饼图的详细教程 文章目录 简单介绍立体柱状图和立体饼图环境配置实现立体柱状图实现立体饼图总结 简单介绍立体柱状图和立体饼图 立体柱状图和立体饼图是数据可视化…...

解决VSCode使用SSH远程连接时无法指定用户名的问题

Windows 11自带OpenSSH客户端&#xff0c;和VSCode配合得很好&#xff0c;没有这个问题。 今天要说的是旧版本Windows 7/8/10系统遇到的问题。 PS: Windows 7可以运行的最后版本是VSCode 1.80.2 由于Windows 7/8/10没有自带的OpenSSH客户端&#xff0c;但可以调用MSYS环境下的…...

Vue Camera是什么,如何用

提示&#xff1a;文章写完后&#xff0c;目录可以自动生成&#xff0c;如何生成可参考右边的帮助文档 文章目录 前言一、pandas是什么&#xff1f;二、使用步骤 1.引入库2.读入数据总结 一、Vue Camera是什么&#xff1f; Vue Camera是一个基于Vue.js的相机组件库&#xff0c;…...

ORANGE室内高尔夫—韩国室内模拟高尔夫原装进口真实体验身临其境

ORANGE室内高尔夫—韩国室内模拟高尔夫 真实体验 身临其境 室内高尔夫的产品优势&#xff1a; 1. 实际高尔夫球场的限制&#xff1a;室内高尔夫可以弥补室外高尔夫球场数量有限的问题&#xff0c;使得更多人能够享受高尔夫运动。 2. 天气和季节的限制&#xff1a;室内高尔夫可…...

【观察】从口袋到云端全景式AI创新,联想“全栈智能”再升级

知名科技杂志《连线》创始主编凯文凯利曾预测&#xff1a;“在未来的 100 年里&#xff0c;人工智能将超越任何一种人工力量&#xff0c;将人类引领到一个前所未有的时代。” 确实如此&#xff0c;犹如历史上蒸汽机、电力、计算机和互联网等通用技术一样&#xff0c;近20年来&a…...

linux 实用命令搜集 —— 筑梦之路

1. xargs命令 # 找出 / 目录下以 .conf 结尾的文件&#xff0c;并进行文件分类find / -name *.conf -type f -print | xargs file# 找出文件并打包find / -name *.conf -type f -print | xargs tar cjf test.tar.gz 2. 查找内存使用量较高的进程 ps -aux | sort -rnk 4 | he…...

08-Docker-网络管理

Docker 在网络管理这块提供了多种的网络选择方式&#xff0c;他们分别是桥接网络、主机网络、覆盖网络、MACLAN 网络、无桥接网络、自定义网络。 1-无桥接网络&#xff08;None Network&#xff09; 当使用无桥接网络时&#xff0c;容器不会分配 IP 地址&#xff0c;也不会连…...

【VS Code】使用 VS Code 登陆远程服务器上的 Docker 容器

以下命令默认已经构建了一个 Docker Image。 # 在服务器上启动 docker (-p 端口映射&#xff0c;用于后续的 ssh 连接) docker run -itd -v /mnt/mount/:/home -p 8124:22 --name container-name --gpus all image-name# 进入容器中 docker exec -it container-name /bin/bas…...

用Python做数据分析之数据统计

接下来说说数据统计部分&#xff0c;这里主要介绍数据采样&#xff0c;标准差&#xff0c;协方差和相关系数的使用方法。 1、数据采样 Excel 的数据分析功能中提供了数据抽样的功能&#xff0c;如下图所示。Python 通过 sample 函数完成数据采样。 2、数据抽样 Sample 是进行…...

智慧工地建造平台源码、智慧化工地云平台源码

概述&#xff1a;智慧工地管理平台充分运用数字化技术&#xff0c;聚焦施工现场岗位一线&#xff0c;依托物联网、互联网、AI等技术&#xff0c;围绕施工现场管理的人、机、料、法、环五大维度&#xff0c;以及施工过程管理的进度、质量、安全三大体系为基础应用&#xff0c;实…...

Spring Cloud Alibaba中Nacos的安装(Windows平台)以及服务的发现

Spring Cloud Alibaba中Nacos的安装&#xff08;Windows平台&#xff09;以及服务的发现 下载安装Nacos解压启动验证是否启动搭建一个简单的Spring Cloud Alibaba项目Spring Cloud Alibaba 以及 Nacos的引入如何选择对应的版本 服务的注册Nacos相关组件的说明 下载安装Nacos G…...

QR码应用实战:Spring Boot与ZXing完美结合

&#x1f38f;&#xff1a;你只管努力&#xff0c;剩下的交给时间 &#x1f3e0; &#xff1a;小破站 QR码应用实战&#xff1a;Spring Boot与ZXing完美结合 前言第一&#xff1a; 介绍QR码和ZXing第二&#xff1a;springboot整合zxing添加ZXing依赖生成二维码生成条形码 前言 …...

Leetcode刷题详解——两两交换链表中的节点

1. 题目链接&#xff1a;24. 两两交换链表中的节点 2. 题目描述&#xff1a; 给你一个链表&#xff0c;两两交换其中相邻的节点&#xff0c;并返回交换后链表的头节点。你必须在不修改节点内部的值的情况下完成本题&#xff08;即&#xff0c;只能进行节点交换&#xff09;。 …...

Openssl数据安全传输平台019:外联接口类的封装以及动态库的制作 - Bug未解决,感觉不是代码的问题

文章目录 1 外联接口1.1 接口类的封装1.2 共享内存与配置文件 2 json格式配置文件的定义2.1 共享内存中存储的节点结构2.2 服务器端配置文件2.3 客户端配置文件2.4 改进配置文件 3 共享内存类修改4 将接口打包成库(静态/动态)4.1 相关的指令4.1.1 静态库4.1.2 动态库 4.2 外联接…...

es在Linux安装

如果服务器能访问外网&#xff1a; wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.4.0.zip不能就手动下载&#xff0c;解压文件到合适目录 unzip elasticsearch-6.4.0.zip -d /opt/ mv /opt/elasticsearch-6.4.0 /opt/elasticsearch创建和日志…...

自由开发者计划 004:创建一个苹果手机长截屏小程序

一. 背景 年初&#xff0c;一个漂亮姐姐突然问我&#xff0c;iphone这么多年一直没法长截屏&#xff0c;你们程序员就没个办法把这个硬伤补上吗&#xff1f; 虎躯一震&#xff0c;脑瓜子嗡嗡的&#xff0c;这么多年的iphone资深用户&#xff0c;最初也不是没有想过这个问题&am…...

Amazon Augmented AI:人类智慧与AI协作,破解机器学习审核难题

在人工智能日益渗透业务核心的今天&#xff0c;你是否遭遇过这样的困境&#xff1a;自动化AI处理海量数据时&#xff0c;面对模糊、复杂或高风险的场景频频“卡壳”&#xff1f;人工审核团队则被低效、重复的任务压得喘不过气&#xff1f;Amazon Augmented AI (A2I) 的诞生&…...

网心云 OEC/OECT 笔记(1) 拆机刷入Armbian固件

目录 网心云 OEC/OECT 笔记(1) 拆机刷入Armbian固件网心云 OEC/OECT 笔记(2) 运行RKNN程序 外观 内部 PCB正面 PCB背面 PCB背面 RK3566 1Gbps PHY 配置 OEC 和 OECT(OEC-turbo) 都是基于瑞芯微 RK3566/RK3568 的网络盒子, 没有HDMI输入输出. 硬件上 OEC 和 OECT…...

[论文阅读] 人工智能+软件工程 | 用大模型优化软件性能

用大模型优化软件性能&#xff1f;这篇论文让代码跑出新速度&#xff01; arXiv:2506.01249 SysLLMatic: Large Language Models are Software System Optimizers Huiyun Peng, Arjun Gupte, Ryan Hasler, Nicholas John Eliopoulos, Chien-Chou Ho, Rishi Mantri, Leo Deng, K…...

数论~~~

质数 质数Miller-Rabin算法质因子分解质数筛埃氏筛欧拉筛如果只是计数&#xff0c;埃氏筛改进 快速幂乘法快速幂矩阵快速幂1维k阶实战(提醒&#xff1a;最好在mul函数中作乘法时加上&#xff08;long long&#xff09;的强制类型转换 &#xff0c;或者全部数组换成long long&am…...

Oracle双平面适用场景讨论会议

4月28日&#xff0c;我在杭州组织召开了Oracle双平面会议讨论沙龙。在国产化数据库浪潮的今天&#xff0c;Oracle数据库作为国产数据库的应急库&#xff0c;在国产数据库发生故障或者性能下降时&#xff0c;如何更好的使用Oracle。会议主题如下&#xff1a; 1、背景与痛点速览&…...

Spring MVC参数绑定终极手册:单多参/对象/集合/JSON/文件上传精讲

我们通过浏览器访问不同的路径&#xff0c;就是在发送不同的请求&#xff0c;在发送请求时&#xff0c;可能会带一些参数&#xff0c;本文将介绍了Spring MVC中处理不同请求参数的多种方式 一、传递单个参数 接收单个参数&#xff0c;在Spring MVC中直接用方法中的参数就可以&…...

django ssh登录 并执行命令

在Django开发环境中&#xff0c;通常不推荐直接通过SSH登录到服务器并执行命令&#xff0c;因为这违背了Django的架构设计原则&#xff0c;即前端与后端分离。Django主要负责处理Web请求、逻辑处理和数据库交互&#xff0c;而不直接执行系统级命令。然而&#xff0c;在某些情况…...

性能优化 - 案例篇:缓存_Guava#LoadingCache设计

文章目录 Pre引言1. 缓存基本概念2. Guava 的 LoadingCache2.1 引入依赖与初始化2.2 手动 put 与自动加载&#xff08;CacheLoader&#xff09;2.2.1 示例代码 2.3 缓存移除与监听&#xff08;invalidate removalListener&#xff09; 3. 缓存回收策略3.1 基于容量的回收&…...