前后端分离

mybatis的分页

配置分页插件

 

使用分页

 
  1. IPage<BookType> iPage = new Page<>(currentPage, pageSize);
  2. iPage = bookTypeDao.selectPage(iPage, null);
  3. List<BookTypeVo> bookTypeVos = new ArrayList<>(100);
  4. for (BookType record : iPage.getRecords()) {
  5. bookTypeVos.add(new BookTypeVo(record));
  6. }
  7. IPage<BookTypeVo> p = new Page<>();
  8. p.setRecords(bookTypeVos);
  9. p.setTotal(iPage.getTotal());
  10. return p;

前端工程化

前后端分离的基础。

vscode, node.js

vscode

配置浏览器

image-20240109105510377

vue

image-20240109105617756

elementUI

image-20240109105712028

other

image-20240109105810549

image-20240109105855433

安装node.js

下载安装

image-20240109110040336

image-20240109110112217

image-20240109110418176

image-20240109110434529

image-20240109110456719

image-20240109110524482

image-20240109110535057

image-20240109110551136

image-20240109110613582

测试

node -v

image-20240109110729749

npm -v

image-20240109110818128

解决vscode运行命令行问题

image-20230713223000269

 
  1. PS C:\Users\Administrator> Get-ExecutionPolicy
  2. Restricted
  3. PS C:\Users\Administrator> Set-ExecutionPolicy RemoteSigned
  4. 执行策略更改
  5. 执行策略可帮助你防止执行不信任的脚本。更改执行策略可能会产生安全风险,如 https:/go.microsoft.com/fwlink/?LinkID=135170
  6. 中的 about_Execution_Policies 帮助主题所述。是否要更改执行策略?
  7. [Y] 是(Y) [A] 全是(A) [N] 否(N) [L] 全否(L) [S] 暂停(S) [?] 帮助 (默认值为“N”): y
  8. PS C:\Users\Administrator>

创建前端项目

image-20240109112010825

image-20240109112240434

安装(npm)

 
  1. npm install -g @vue/cli@4.5.15

image-20240109112455410

创建vue-cli项目

检测vue版本
 
  1. PS D:\wnhz-09-workspace\wnhz-2048> vue --version
  2. @vue/cli 4.5.15
创建项目
 
  1. vue create wnhz-web

image-20240109120022945

项目配置

选择: Default(第一项)

image-20240109120112950

image-20240109120252474

image-20240109120840224

测试

image-20240109121011131

image-20240109120954805

添加淘宝镜像

 
  1. npm install -g cnpm --registry=https://registry.npm.taobao.org
  2. npm config set registry https://registry.npm.taobao.org

安装elementUI

npm安装

 
  1. npm i element-ui -S

image-20240109140642437

配置

image-20240109140941654

image-20240109141129511

main.js中配置全局elementUI

image-20240109141806605

使用vue
 
  1. <template>
  2. ---只能有一个根标签
  3. </template>
在App中引入组件

import Nav from ‘./components/Nav.vue’

定义组件
 
  1. export default {
  2. name: 'App',
  3. components: {
  4. HelloWorld,
  5. Nav
  6. }
  7. }
使用组件
 
  1. <template>
  2. <div id="app">
  3. <img alt="Vue logo" src="./assets/logo.png">
  4. <HelloWorld msg="我的第一个vue项目^_^"/>
  5. <Nav/>
  6. </div>
  7. </template>

路由

Vue Router | Vue.js 的官方路由 (vuejs.org)

image-20231220110810537

Vue Router 是 Vue.js 的官方路由。它与 Vue.js 核心深度集成,让用 Vue.js 构建单页应用变得轻而易举。功能包括:

  • 嵌套路由映射
  • 动态路由选择
  • 模块化、基于组件的路由配置
  • 路由参数、查询、通配符
  • 展示由 Vue.js 的过渡系统提供的过渡效果
  • 细致的导航控制
  • 自动激活 CSS 类的链接
  • HTML5 history 模式或 hash 模式
  • 可定制的滚动行为
  • URL 的正确编码

安装路由

 
  1. npm i vue-router@3.5.3

image-20231220111320325

image-20231220111457479

router使用

创建路由文件
src/router文件

image-20230626224313871

创建路由index.js

image-20230626224429822

在main.js中配置路由
 
  1. import Vue from 'vue'
  2. import App from './App.vue'
  3. Vue.config.productionTip = false
  4. import router from './router'
  5. Vue.use(router)
  6. new Vue({
  7. render: h => h(App),
  8. router,
  9. }).$mount('#app')
页面
  • Nav.vue

  • Tab.vue

    image-20240109153931330

配置路由

image-20240109154418394

页面跳转
  • js代码

     
      
    1. showTab(){
    2. window.location.href= '/#/tab'
    3. }

axios

安装axios

 
  1. npm install axios

image-20240109165102570

配置工具

 
  1. //定义全局axios的请求对象工具
  2. import axios from 'axios'
  3. const $request = axios.create({
  4. timeout: 10000
  5. });
  6. //前端拦截器
  7. $request.interceptors.request.use(
  8. config=>{
  9. config.headers['Content-Type']='application/json;charset=utf-8';
  10. return config;
  11. },error=>{
  12. return Promise.reject(error);
  13. }
  14. );
  15. export default $request;

使用ajax

VUE: MVVM

组件生命周期图示

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值