vue路由传参+案例(使用mock模拟后端数据)

news2024/9/20 16:32:48

路由传参

跳转路由时,可以给路由对应的组件内传参

声明式导航

/path?参数名=值
/path/值 —需要路由对象提前配置 path: ‘/path/:参数名’

对应的页面组件接收传递过来的值

$route.query.参数名
$route.params.参数名

router/index.js

import Vue from 'vue'
// 1. 导入路由
import VueRouter from "vue-router"

// 引入组件
// import Home from '../views/Home'
// import Login from '../views/Login'
// import Register from '../views/Register'

// 2. 使用路由插件
// 在vue中,使用vue插件,需要调用Vue.use()
Vue.use(VueRouter)

// 3. 创建路由规则
const routes = [
    {
        path: '/',
        redirect: '/list'
    },
    {
        path: '/list',
        component: () => import('../views/List')
    },
    {
        path: '/part',
        component: () => import('../views/Part')
    },
    {
        path: '/detail/:name',
        component: () => import('../views/Detail')
    },
    {
        path: '*',
        component: () => import('../views/NotFound')
    },
]

// 4. 创建路由对象,传入规则
const router = new VueRouter({
    // routes: routes,
    routes,
    mode: 'history',
})

// 导出路由对象
export default router

App.vue

<template>
  <div>
    <router-view></router-view>
  </div>
</template>

<script>
export default {

}
</script>

<style scoped></style>

List.vue

<template>
    <div>
        <router-link to="/part?name=张三">好友---张三</router-link>
        <router-link to="/detail/王五">好友---王五</router-link>
        // to一定要加: 进行属性绑定,动态属性传值
        <router-link :to="'/part?name='+ n1">朋友---{{ n1 }}</router-link>
        <router-link :to="'/detail/'+ n2">朋友---{{ n2 }}</router-link>
    </div>
</template>

<script>
export default {
    data() {
        return {
            n1: '小米',
            n2: '小鹏',
        }
    },
}
</script>

<style scoped></style>

Part.vue

<template>
    <div>
        <p>关注的人</p>
        // 方式 1
        {{ $route.query.name }}
        <hr>
        {{ name }}
    </div>
</template>

<script>
export default {
    data() {
        return {
            name: '',
        }
    },
    created() {
        // 创建完成 第一次操作data中数据执行一次
        this.name = this.$route.query.name
        console.log(this.name);
    }
}
</script>

<style scoped></style>

Detail.vue

<template>
    <div>
        detail
        // 方式 2
        <p>{{ $route.params.name }}</p>
        <hr>
        {{ name }}
    </div>
</template>

<script>
export default {
    data() {
        return {
            name: '',
        }
    },
    created() {
        this.name = this.$route.params.name
    }
}
</script>

<style scoped></style>

在这里插入图片描述

编程式导航

语法:
query/params 任选一个

this.$router.push({
		path: "路由路径",
		name: "路由名",
		query: {
			"参数名": "值",
		},
		params: {
			"参数名": "值",
		},
})

List.vue

<template>
    <div>
        <router-link to="/part?name=张三">好友---张三</router-link>
        <router-link to="/detail/王五">好友---王五</router-link>
        <router-link :to="'/part?name=' + n1">朋友---{{ n1 }}</router-link>
        <router-link :to="'/detail/' + n2">朋友---{{ n2 }}</router-link>
        <hr>
        <span @click="fn1">朋友---{{ n1 }}</span>
        <span @click="fn2">朋友---{{ n2 }}</span>
    </div>
</template>

<script>
export default {
    data() {
        return {
            n1: '小米',
            n2: '小鹏',
        }
    },
    methods: {
        fn1() {
            this.$router.push({
                path: '/part',
                query: {
                    // name: '小米',
                    name: this.n1,
                }
            })
        },
        fn2() {
            // this.$router.push({
            //     // 不能用path,path会自动忽略params
            //     name: 'detail',
            //     params: {
            //         name: this.n2,
            //     }
            // })
            this.$router.push('/detail/' + this.n2) 
        },
    },
}
</script>

<style scoped></style>

路由守卫

https://router.vuejs.org/zh/guide/advanced/navigation-guards.html

vue-router 提供的导航守卫主要用来通过跳转或取消的方式守卫导航。这里有很多方式植入路由导航中:全局的,单个路由独享的,或者组件级的。

全局前置守卫

需求:在跳转路由前,判断用户是否登录,登录了才能跳转到"part"页面,未登录弹窗提示
在路由对象上使用固定的方法 beforeEach()


// 1. 在路由对象上使用固定的方法 beforeEach(一定要在创建路由之后使用该方法)
/*

路由跳转"之前"先执行这里,决定是否跳转
router.beforeEach((to, from, next)=>{
to 要跳转的路由(路由对象信息) 目标 
from 从哪里跳转的路由(路由对象信息) 来源
next 函数体,next()  才会让路由正常的跳转切换,next(false)在原地停留  next("路由路径") 强制修改到另一个路由路径上
不调用next 页面留在原地
})

*/
// 在跳转路由前,判断用户是否登录,登录了才能跳转到"part"页面,未登录弹窗提示
const isLogin = false  // 登录状态(未登录)
router.beforeEach((to, from, next) => {
    // console.log(to)
    // console.log(from)
    if (to.path === '/part' && isLogin === false) {
        alert('请先登录')
        next(false)
    } else {
        next()  // 正常放行
    }
})

Vant组件库

https://vant-contrib.gitee.io/vant/v2/#/zh-CN/

Vant轻量、可靠的移动端 Vue 组件库

安装

在当前项目根目录中打开终端输入以下命令

npm i vant@latest-v2 -S

导入所有的组件

main.js中导入

// 导入所有的组件
import Vant from 'vant'
import 'vant/lib/index.css'

Vue.use(Vant)

使用组件

<van-button type="primary">主要按钮</van-button>
<van-button type="info">信息按钮</van-button>
<van-button type="default">默认按钮</van-button>
<van-button type="warning">警告按钮</van-button>
<van-button type="danger">危险按钮</van-button>

手动按需引入

只引入使用的组件

在不使用插件的情况下,可以手动引入需要的组件 —每一个组件都要引入

import Button from 'vant/lib/button';
import 'vant/lib/button/style';

注册
List.vue

<template>
  <div>
    <van-button type="primary">主要按钮</van-button>
    <van-button type="info">信息按钮</van-button>
    <van-button type="default">默认按钮</van-button>
    <van-button type="warning">警告按钮</van-button>
    <van-button type="danger">危险按钮</van-button>
  </div>
</template>

<script>
// 组件要引入到要显示组件的那个vue中
import Button from "vant/lib/button";
import "vant/lib/button/style";
export default {
  components: {
    // VanButton: Button,
    [Button.name]: Button,
  },
};
</script>

自动按需引入

babel-plugin-import 是一款 babel 插件,它会在编译过程中将 import 的写法自动转换为按需引入的方式。

安装插件

npm i babel-plugin-import -D

在babel.config.js中配置完,要重新启动项目

module.exports = {
  presets: [
    '@vue/cli-plugin-babel/preset'
  ],
  plugins: [
    ['import', {
      libraryName: 'vant',
      libraryDirectory: 'es',
      style: true
    }, 'vant']
  ]
};

main.js

import { Button, Icon } from 'vant'
Vue.use(Button)
Vue.use(Icon)

组件中使用

<template>
  <div>
    <van-button type="primary">主要按钮</van-button>
    <van-button type="info">信息按钮</van-button>
    <van-button type="default">默认按钮</van-button>
    <van-button type="warning">警告按钮</van-button>
    <van-button type="danger">危险按钮</van-button>
    <van-icon name="chat-o" />
    <van-icon name="https://b.yzcdn.cn/vant/icon-demo-1126.png" />
  </div>
</template>

<script>
export default {};
</script>

<style scoped>
</style>

案例

路由配置

二级路由
组件

  • Layout.vue —总的框架
  • List.vue —商品列表
  • Search.vue —商品搜索
  • My.vue —我的信息

配置路由

import Vue from "vue";

import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
    {
        path: '/',
        redirect: '/list',
        component: () => import('../views/Layout'),
        children: [
            {
                path: '/list',
                component: () => import('../views/List'),
            },
            {
                path: '/my',
                component: () => import('../views/My'),
            },
            {
                path: '/search',
                component: () => import('../views/Search'),
            },
        ]
    },
    {
        path: '*',
        component: () => import('../views/NotFound')
    }
]

const router = new VueRouter({
    routes,
    mode: 'history'
})

export default router

底部封装

  • 创建MyTabBar.vue组件
<template>
  <div>
    <van-tabbar v-model="active">
      <van-tabbar-item icon="home-o" to="/list">商品列表</van-tabbar-item>
      <van-tabbar-item icon="search" to="/search">商品搜索</van-tabbar-item>
      <van-tabbar-item icon="friends-o" to="/my">我的信息</van-tabbar-item>
    </van-tabbar>
  </div>
</template>

<script>
export default {
  data() {
    return {
      active: 0,
    };
  },
};
</script>

<style scoped>
</style>

顶部封装

  • 创建MyHead.vue组件
<template>
  <div>
    <div class="head">TabBar案例</div>
  </div>
</template>

<script>
export default {};
</script>

<style scoped>
.head {
  height: 50px;
  line-height: 50px;
  color: #fff;
  background-color: blue;
  text-align: center;
}
</style>

MyTabBar.vue组件和MyHead.vue组件要注册并引入到 Layout.vue 组件中

商品列表

  • 封装MyTable.vue === 标签和样式
  • axios在MyGoodList.vue请求数据回来,把MyTable.vue引入到MyGoodList.vue中,再把MyGoodList.vue引入到List.vue中
  • 请求地址https://www.escook.cn/api/goods
  • 传入MyTable.vue中循环数据显示

List.vue

<template>
    <div>
        <my-good-list></my-good-list>
    </div>
</template>

<script>
import MyGoodList from '@/components/MyGoodList.vue'
export default {
    components: { MyGoodList, }
}
</script>

<style scoped></style>

MyTable.vue

<template>
  <div>
    <table>
      <thead>
        <tr>
          <th>#</th>
          <th>名称</th>
          <th>价格</th>
          <th>标签</th>
          <th>操作</th>
        </tr>
      </thead>
      <tbody>
        // 循环遍历渲染数据
        <tr v-for="(item, index) in list">
          <td>{{ item.id }}</td>
          <td>{{ item.goods_name }}</td>
          <td>{{ item.goods_price }}</td>
          <td>{{ item.tags }}</td>
          <td>
            <van-button type="primary">删除</van-button>
          </td>
        </tr>
      </tbody>
    </table>
  </div>
</template>

<script>
export default {
  // 子组件props接收
  props: {
    list: Array,
  },
};
</script>

<style scoped>
table {
  width: 100%;
  border: 1px solid #eee;
  border-collapse: collapse;
  margin: 20px auto;
}
td,
th {
  height: 30px;
  border: 1px solid #eee;
}
</style>

axios在MyGoodList.vue请求数据回来

  • 下载axios
yarn add axios

MyGoodList.vue

<template>
  <div>
    // 父传子 父自定义属性
    <my-table :list="list"></my-table>
  </div>
</template>

<script>
import axios from "axios";
import MyTable from "./MyTable.vue";
export default {
  data() {
    return {
      list: [],
    };
  },
  components: {
    MyTable,
  },
  create() {
    // axios({
    //   url: "https://www.escook.cn/api/goods",
    // }).then((res) => {
    //   let {
    //     data: { data: result },
    //   } = res;
    //   console.log(result);
    // });
    this.getData();
  },
  methods: {
    async getData() {
      let {
        data: { data: result },
      } = await axios({ url: "https://www.escook.cn/api/goods" });
      console.log(result);
      this.list = result;
    },
  },
};
</script>

<style scoped>
</style>

商品表格—插槽

使用插槽技术,和作用于插槽技术,给MyTable.vue组件,自定义标题,自定义列标题,自定义表格内容

需求:允许用户自定义表头和表格单元格内容

  • 在MyTable.vue中准备slot
  • 使用MyTable组件时传入具体标签

步骤:

  • 提高组件==复用性和灵活性 ==,把表格列标题thead部分预留slot,设置 name 属性
  • 使用MyTable.vue时,传入列标题标签
  • 表格内容 td 部分也可以让组件使用者自定义,也给tbody预留 slot 和 name属性
  • 使用插槽需要用到插槽内的item对象上的数据,作用域插槽

MyTable.vue

<template>
  <div>
    <table>
      <thead>
        <tr>
          // <th>#</th>
          // <th>名称</th>
          // <th>价格</th>
          // <th>标签</th>
          // <th>操作</th>
          <slot name="header"></slot>
        </tr>
      </thead>
      <tbody>
        <!-- 循环遍历渲染数据 -->
        <tr v-for="(item, index) in list">
          // <td>{{ item.id }}</td>
          // <td>{{ item.goods_name }}</td>
          // <td>{{ item.goods_price }}</td>
          // <td>{{ item.tags }}</td>
          // <td>
          //   <van-button type="primary">删除</van-button>
          // </td>
          <slot name="body" :row="item" :index="index"></slot>
        </tr>
      </tbody>
    </table>
  </div>
</template>

<script>
export default {
  // 子组件props接收
  props: {
    list: Array,
  },
};
</script>

<style scoped>
table {
  width: 100%;
  border: 1px solid #eee;
  border-collapse: collapse;
  margin: 20px auto;
}
td,
th {
  height: 30px;
  border: 1px solid #eee;
}
</style>

MyGoodList.vue

<template>
  <div>
    <!-- 父传子 父自定义属性 -->
    <my-table :list="list">
      <template #header>
        <th>#</th>
        <th>名称</th>
        <th>价格</th>
        <th>标签</th>
        <th>操作</th>
      </template>
      <template #body="{ row, index }">
        <td>{{ row.id }}</td>
        <td>{{ row.goods_name }}</td>
        <td>{{ row.goods_price }}</td>
        <td>{{ row.tags }}</td>
        <td>
          <van-button type="primary">删除</van-button>
        </td>
      </template>
    </my-table>
  </div>
</template>

mock模拟后端数据

由于上面使用的接口挂了,所以改用mock模拟后端数据,并对axios进行了简单的二次封装

axios二次封装

src/utils/request.js

// 二次封装axios

import axios from 'axios'

const http = axios.create({
    // 通用请求的地址前缀
    baseURL: '/api',
    timeout: 10000, // 超时时间
})

// 添加请求拦截器
http.interceptors.request.use(function (config) {
    // 在发送请求之前做些什么
    return config;
}, function (error) {
    // 对请求错误做些什么
    return Promise.reject(error);
});

// 添加响应拦截器
http.interceptors.response.use(function (response) {
    // 2xx 范围内的状态码都会触发该函数。
    // 对响应数据做点什么
    return response;
}, function (error) {
    // 超出 2xx 范围的状态码都会触发该函数。
    // 对响应错误做点什么
    return Promise.reject(error);
});


export default http // 对外暴露 http 实例

封装getData方法对外暴露,使用http.get()请求列表页数据

arc/api/index.js

import http from '../utils/request'

// 请求列表页数据
export const getData = () => {
    // 返回一个promise对象
    return http.get('/list/getData')
}

MyGoodList.vue中调用getData方法请求数据

MyGoodList.vue

import { getData } from '../api'
export default {
    created() {
        getData().then(({ data: { data: { data: list } } }) => {  // 解构得到请求的数据
            console.log(list)
            this.list = list
        })
    },
}

定义mock请求拦截

api/mock.js

import Mock from 'mockjs'
import listApi from './mockServeData/list'

// 定义mock请求拦截
Mock.mock('/api/list/getData', listApi.getStatisticalData)

// // 定义mock请求拦截
// Mock.mock('/api/home/getData', function () {
//     // 拦截到请求后的处理逻辑
//     console.log('拦截到了')
//     return []
// })

main.js中引入mock

main.js中配置

import './api/mock'

mock模拟列表数据

api/mockServeData/list.js

mock模拟列表数据

// 列表数据
// mock数据模拟
import Mock from 'mockjs'
export default {
    getStatisticalData: () => {
        return {
            code: 20000,
            data: {
                data: [
                    {
                        id: 1001,
                        goods_name: '小米',
                        goods_price: 2999,
                        tags: ['性价比', '高性能'],
                        inputValue: '',
                        inputVisible: false,
                    },
                    {
                        id: 1002,
                        goods_name: '魅族',
                        goods_price: 2999,
                        tags: ['性价比', '高性能'],
                        inputValue: '',
                        inputVisible: false,
                    },
                    {
                        id: 1003,
                        goods_name: '华为',
                        goods_price: 2999,
                        tags: ['高性能'],
                        inputValue: '',
                        inputVisible: false,
                    },
                    {
                        id: 1004,
                        goods_name: '荣耀',
                        goods_price: 2999,
                        tags: ['高性能'],
                        inputValue: '',
                        inputVisible: false,
                    },
                    {
                        id: 1005,
                        goods_name: 'oppo',
                        goods_price: 2999,
                        tags: ['高性能'],
                        inputValue: '',
                        inputVisible: false,
                    },
                    {
                        id: 1006,
                        goods_name: 'vivo',
                        goods_price: 2999,
                        tags: ['高性能'],
                        inputValue: '',
                        inputVisible: false,
                    }
                ],
            }
        }
    }
}


商品表格tags

main.js中按需引入Tag组件

<td>
	<van-tag v-for="(item, ind) in row.tags" :key="ind" type="primary">
	{{ item }}
	</van-tag>
</td>

商品表格—删除功能

点击删除按钮删除对应行的数据
main.js中按需引入Button组件

分析:

  • 删除按钮绑定点击事件
  • 作用域插槽绑定id
  • 传给删除方法,删除MyGoodList.vue里面数组的数据

MyGoodList.vue—注册点击事件

 <van-button type="primary" @click="removeBtn(row.id)">删除</van-button>

MyGoodList.vue 根据id删除数据

    methods: {
        removeBtn(id) {
            // 1. 根据id查找下标
            let index = this.list.findIndex((obj) => obj.id === id)
            // 2. 实现删除
            this.list.splice(index, 1)
        }
    },

商品表格—添加tab

需求:店家tab按钮,出现输入框自动获取焦点,失去焦点关闭输入框,会出新增tag,esc清空内容

main.js中按需引入Button组件、Field组件

  • 点击tab,按钮消失,输入框出现
  • 输入框自动获焦
  • 失去焦点,输入框消失,按钮出现
  • 监测输入框回车,若无数据进行拦截,有数据则添加
  • input输入框 按esc清空数据

点击tab,按钮消失,输入框出现

<td>
	<div class="top">
		<van-field 
		v-model="value" 
		v-if="row.inputVisible" 
		placeholder="请输入新标签" />
		<van-button 
		type="info" 
		size="small" 
		v-else 
		@click="row.inputVisible = true">Tag+</van-button>
	</div>
	<van-tag type="primary" v-for="(item, ind) in row.tags" :key="ind"> {{ item }} </van-tag>
</td>

输入框自动获焦

Vant组件使用autofocus自动获焦

<van-field 
v-model="value" 
v-if="row.inputVisible" 
placeholder="请输入新标签" 
:autofocus="true" />

失去焦点,输入框消失,按钮出现

blur事件 输入框失去焦点时触发

<van-field 
v-model="value" 
v-if="row.inputVisible" 
placeholder="请输入新标签" 
:autofocus="true" 
@blur="row.inputVisible = false"/>

监测输入框回车,若无数据进行拦截,有数据则添加

输入框要双向绑定mock数据中的inputValue
利用该数据中的inputValue添加标签内容到row.tags

  1. 监听input的回车事件
<van-field 
v-model="row.inputValue" 
v-if="row.inputVisible" 
placeholder="请输入新标签" 
:autofocus="true"
@blur="row.inputVisible = false" 
@keyup.enter="enterFn(row)" />
  1. 事件处理函数
// 在methods方法中定义enterFn方法
enterFn(row) {
	// console.log(row);
	// 非空判断
	if (row.inputValue.trim().length === 0) {
		return alert('添加标签不能为空!')
	}
	// 添加
	row.tags.push(row.inputValue)
	row.inputValue = ''
}

input输入框 按esc清空数据

  1. 监听input的esc事件
<van-field 
v-model="row.inputValue" 
v-if="row.inputVisible" 
placeholder="请输入新标签" 
:autofocus="true"
@blur="row.inputVisible = false" 
@keyup.enter="enterFn(row)" 
@keyup.esc="clearFn(row)"/>
  1. 事件处理函数
clearFn(row) {
	row.inputValue = ''
}

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

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

相关文章

解析matlab的audioread()输入输出参数

目录 一、API简介 二、实验 1. matlab 2. C语言 一、API简介 链接如下&#xff1a; 读取音频文件 - MATLAB audioread- MathWorks 中国 也可以浏览最新的英文版API说明&#xff1a; 简单说明如下&#xff1a; 1. 读取wav格式的文件&#xff0c;会自动跳过44个字节的文件…

初识React/JSX/组件/state/受控组件

JSX 推荐使用小括号包裹jsx 使用函数创建组件 使用类创建组件 抽离组件 事件绑定 事件对象 有状态和无状态组件/state 抽离事件处理程序 表单元素 受控组件 多表单优化 非受控组件(了解即可)

vhost-net-原理-初始化流程-数据传输流程-vhost-net后端

文章目录 1.vhost net2.vhost-net的初始化流程vhost net设置vhost dev设置vhost vring设置 3.数据收发流程分析3.1 数据发送3.2 数据接收 4ioventfd和irqfd的通知机制4.1ioeventfdqemu侧kvm侧总体效果 4.2irqfdqemu侧kvm侧总体效果 参考&#xff1a; 1.vhost net 传统的virtio…

ChatGPT Plugins内幕、源码及案例实战(一)

ChatGPT Plugins内幕、源码及案例实战 6.1 ChatGPT Plugins的工作原理 本节主要跟大家谈ChatGPT的插件(Plugins),这个内容非常重要。现在很多企业级的开发,一般都会基于ChatGPT 插件进行一些服务的封装,相当于开发了一个代理(Agent),把一些服务或者API封装在里面,然后…

eclipse编辑器汉化;eclipse安装中文插件

eclipse IDE默认是英文环境&#xff0c;使用起来略微不便&#xff0c;汉化还是很有必要的&#xff1b;下面记录一下安装中文插件的过程: 文章目录 一、 选择安装包地址二、 在eclipse安装中文插件2.1 在线安装2.2 手动下载安装包2.3 导入到eclipse 三、汉化插件介绍 一、 选择安…

实例005 可以拉伸的菜单界面

实例说明 如果管理程序功能菜单非常多&#xff0c;而用户只使用一些常用菜单&#xff0c;这时&#xff0c;可以将主菜单项下的不常用菜单隐藏起来。此种显示方式类似于对菜单进行拉伸。使用时&#xff0c;只需单击展开菜单&#xff0c;即可显示相应菜单功能。运行本例&#xf…

python matplotlib中colorbar的位置设置

colorbar单独设置一个轴对象&#xff0c;再对轴对象进行灵活设置 import numpy as np import matplotlib.pyplot as plt# 创建一个二维随机数组 data np.random.rand(10, 10)# 创建一个图形和一个子图 fig, ax plt.subplots()# 绘制热力图 heatmap ax.imshow(data, cmaphot…

在linux中快速安装Redis数据库

Redis中文网 点击该链接下载最5.0.4版本的Redis的压缩包 使用Xftp工具将Redis安装包上传到linux中 1.将压缩包解压到/opt目录下: tar -zxvf redis-5.0.4.tar.gz 2. 更新yun: sudo yum makecache fast 3.安装gcc: yum -y install gcc 4.安装完成通过输入 : gcc -v …

tiny tool - get_file_path_name_by_drop_file

文章目录 tiny tool - get_file_path_name_by_drop_file概述工程效果收获的知识点vs2022工程, 必须自己设置对话框可以接受文件的风格vs2022建立的工程, 默认是unicode编码, 设置剪贴板数据时, 必须要设置为unicode的格式, 否则剪切板中只有第一个字符工程主要实现END tiny too…

短信压力测试系统,支持自定义接口

短信压力测试系统,支持自定义接口 支持卡密充值&#xff0c;短信压力测试系统&#xff0c;解决一切骚扰电话&#xff0c;教程在压缩包里面 可多个服务器挂脚本分担压力&#xff0c;套了cdn导致无法正常执行脚本可以尝试添加白名单 这边建议使用MySQL方式 同服务器下直接配置…

MySQL生产环境高可用架构实战

分布式技术MongoDB 1. MySQL高可用集群介绍1.1 数据库主从架构与分库分表1.2 MySQL主从同步原理 2. 动手搭建MySQL主从集群2.1 基础环境搭建2.2 安装MySQL服务2.2.1 初始化MySQL2.2.2 启动mysql2.2.3 连接MySQL 2.3 搭建主从集群2.3.1 配置master主服务2.3.2 配置slave从服务主…

Radzen Blazor Studio 1.12 Crack

Radzen Blazor Studio 是一款桌面工具&#xff0c;使 开发人员 能够创建精美的商业 Blazor 应用程序。快速地。 开放技术栈 没有供应商锁定。生成的源代码是人类可读的&#xff0c;您可以使用免费工具构建它。 Radzen 由流行的开源技术 - ASP.NET Core、Blazor、Bootstrap 提供…

较少的分区也报错too many range table entries

问题现象 postgresql中update执行语句报错too many range table entries 源sql with t as (select id from LZLTAB where id8723 limit 100 ) update LZLTAB setSTATUS 00,FILE_ID null,DATE_UPDATED localtimestamp(0) where id in (select id from t)如果把update改写成…

碳排放预测模型 | Python实现基于机器学习的碳排放预测模型——数据清理和可视化

文章目录 效果一览文章概述研究内容源码设计参考资料效果一览 文章概述 碳排放预测模型 | Python实现基于机器学习的碳排放预测模型——数据清理和可视化 研究内容 碳排放被认为是全球变暖的最主要原因之一。 该项目旨在提供各国碳排放未来趋势的概述以及未来十年的全球趋势预测…

三维空间刚体运动之旋转矩阵与变换矩阵

1. 旋转矩阵 1.1 点、向量和坐标系 点&#xff1a;点是空间中的基本元素&#xff0c;没有长度&#xff0c;没有体积&#xff1b; 向量&#xff1a;把两个点连接起来&#xff0c;就构成了向量&#xff0c;向量可以看成从某点指向另一点的一个箭头&#xff1b;只有当我们指定这…

threejs精灵和粒子系统

个人博客地址: https://cxx001.gitee.io 前面我们了解到了场景中的网格对象由几何体和材质组成&#xff0c;并且分别系统学习了它们。这节我们将学习一个特殊的网格对象-----粒子(精灵)。 了解粒子 一个粒子(新版叫精灵)是 一个二维平面(小方块) &#xff0c;它总是面向摄像…

Linux--阅读文本指令:more、less

生成10000行数字并将其写入普通文件的指令&#xff1a; count0; while [ $count -le 10000 ]; do echo "hello bit ${count}"; let count; done > file.txt 直接cat < file.txt会刷屏的&#xff0c;故引入more 注&#xff1a;enter键控制下翻&#xff0c;q直…

拷贝对象,拷贝快乐:揭开JavaScript中拷贝的神奇面纱

文章目录 浅拷贝&#xff08;Shallow Copy&#xff09;1. 使用 Object.assign() 方法2. 使用展开运算符&#xff08;Spread Operator&#xff09;3. 使用数组的 slice() 或 concat() 方法 深拷贝&#xff08;Deep Copy&#xff09;1. 使用 JSON 对象的方法2. 使用递归方法自行实…

@validated的自定义注解校验编程式校验

自定义注解校验 前面的文章中&#xff0c;我们都是采用validate机制自带的条件注解来进行参数校验&#xff0c; 比如Min、NotNull…等等&#xff0c; 这些的确可以帮我们省去一部分的参数校验&#xff0c;可惜还有一部分的业务校验规则并不是如这般简单的&#xff0c; 比如前端…

C++ 程序设计入门

✅作者简介&#xff1a;人工智能专业本科在读&#xff0c;喜欢计算机与编程&#xff0c;写博客记录自己的学习历程。 &#x1f34e;个人主页&#xff1a;小嗷犬的个人主页 &#x1f34a;个人网站&#xff1a;小嗷犬的技术小站 &#x1f96d;个人信条&#xff1a;为天地立心&…