SpringBoot+Vue前后端分离实现高并发秒杀——前端知识总结
一、Vue项目构建
vue init webpack 项目名 // 适用于大型项目
vue init webpack-simple 项目名 // 适用于小型项目
cd 项目名
npm install //安装依赖
npm run dev //运行项目
二、Vue基本语法,数据绑定,组件
v-bind 绑定文本,属性,表达式,可缩写为 :
v-model 多用于表单中可以绑定text,radio,checkbox,selected
v-html 用于输出html代码
v-if ,v-else-if ,v-else根据表达式值来决定是否插入该元素,v-else-if ,v-else必须紧跟在v-if或v-else-if后
v-on 用于监听DOM事件,可缩写为 @
v-show 用于展示元素
v-for 循环v-for="(val,index) in value" :key=index
computed:{} 计算属性,基于它的依赖缓存
methods:{} 重新渲染时,函数总会重新调用
watch:{} 监听属性
components:{} 组件
vue.js学习地址:https://cn.vuejs.org/v2/guide/
三、vue-router使用
安装 npm install vue-router -d
<router-link\ to="/url"></router-link>
<router-view></router-view> 路由出口,路由匹配到的组件将渲染在这里
import 名称 from ‘组件路径’
{path: ‘路径’,
componet: 名称,
children:[{
path:‘路径’,
component: 名称
}]
}
vue-router学习地址:https://router.vuejs.org/zh/
四、Element-ui使用
安装 npm install element-ui –d
引入import Element from ‘element-ui’
import ‘element-ui/lib/theme-chalk/index.css’
Vue.use(element-ui)
element-ui学习地址:https://element.eleme.cn/#/zh-CN/component/quickstart
五、Axios发送请求
npm install axios -d
vue-axios: npm install vue-axios –d
qs: npm install qs –d
引入import Axios from ‘axios’
import VueAxios from ‘vue-axios’
import Qs from ‘qs’
Vue.use(VueAxios,Axios)
Vue.use(Qs)
Axios.defaults.baseURL = ‘http://127.0.0.1:8888’
Axios.defaults.headers[‘Content-Type’] = ‘application/x-www-form-urlencoded;charset=UTF-8’
Axios.defaults.withCredentials = true
axios学习地址:https://github.com/axios/axios
六、Vuex管理状态
npm install vuex –d
import Vuex from ‘vuex’
Vue.use(Vuex)
vuex学习地址:https://vuex.vuejs.org/zh/
七、Vue项目去掉url后的#
//基于webpack-simple修改vue-router模式为history
import VueRouter from ‘vue-router’
Vue.use(VueRouter)
const router = new VueRouter({
mode: ‘history’
})
//基于webpack修改index.js文件
export default new Router({
mode: ‘history’
})
八、Vue项目打包发布到Nginx
npm run build
将dist目录和index.html放到服务器上
修改nginx配置文件/etc/nginx/conf.d/default.conf
添加类容:
server{
listen 8080;
location / {
root /usr/local/seckill;
index index.html;
try_files $uri $uri/ /index.html;
}
}
如果vue-router模式为history需加上try_files $uri $uri/ /index.html;不然会404
配置端口号,服务器dist和index.html目录,首页等
启动命令nginx
停止命令nginx -s stop
- vue+springboot前后端分离实现单点登录跨域问题解决方法
- SpringBoot+Vue.js实现前后端分离的文件上传功能
- idea+HBuilderX实现springboot+springdata-jpa+vue+axios前后端分离增删改查,分页+解决跨域问题的idea页面
- Spring Boot + Vue 前后端分离开发,前端网络请求封装与配置
- swagger+springboot实现前(vue)后端分离
- ajax + vue + springboot + Restful实现前后端分离项目
- ueditor在vue+springboot前后端分离项目图片上传配置踩坑总结
- 基于springboot+vue+element+ueditor实现前后端分离的富文本框实现
- vue+springboot前后端分离实现单点登录跨域问题解决方法
- 搭建spring-boot+vue前后端分离框架并实现登录功能
- Spring Boot + Vue 前后端分离开发,前端网络请求封装与配置
- Springboot + Vue + shiro 实现前后端分离、权限控制
- springboot整合shiro-spring-boot-web-starter实现前后端分离的跨域问题
- 前后端分离框架前端react,后端springboot跨域问题分析
- 基于CAS的单点登录SSO[5]: 基于Springboot实现CAS客户端的前后端分离
- SpringBoot+Vue前后端分离,使用SpringSecurity完美处理权限问题的解决方法
- 前后端分离后台基于springboot,shiro,auth2,前端vue集成cas
- spring boot+vue 的前后端分离与合并方案实例详解
- 分享一个前后端分离的web项目(vue+spring boot)
- 【SpringBoot商城秒杀系统项目实战18】页面优化技术-商品详情页面静态化(前后端分离)