基于uniapp vue3.0 uView 做一个点单页面(包括加入购物车动画和左右联动)

1、实现效果:

下拉有自定义组件(商品卡片、进步器、侧边栏等)源码

2、左右联动功能

使用scroll-view来做右边的菜单页,title的id动态绑定充当锚点

<scroll-view :scroll-into-view="toView" scroll-with-animation="true" class="main" @scroll="scroll" scroll-y>
				<view class="scroll_main">
					<view class="" v-for="(item,index) in list" :id="'type' + index">
						<view :id="'title' + index">
							<u-divider>{{item.meal_name}}</u-divider>
						</view>
						<card v-for="(item2,indax) in item.goods" :data="item2" @change="cardChange"></card>
					</view>
				</view>
			</scroll-view>

侧边栏组件点击事件,返回分类信息,根据分类的id,定位到scroll-view对应的title

<view class="nav">
				<left-nav :data="list" :current="current" @change="navChange"></left-nav>
			</view>
function navChange(e) {
		current.value = e
		getRightScrollDistance()
	}

 scroll-view属性@scroll用于监听scroll的滚动距离,注意用防抖(我用的是uView里自带的防抖方法),防止nav跳动

获取每个titile距离盒子顶部的距离,用于判断滚动距离是否超出某个分类

onReady(() => {
		list.value.forEach((item, index) => {
			uni.createSelectorQuery().select('#title' + index).boundingClientRect(data => {
				console.log(data);
				titleH.value.push(data)
			}).exec()
		})
	})

获取“this”:

const {
		appContext: {
			app: {
				config: {
					globalProperties
				}
			}
		}
	} = getCurrentInstance()
/* 菜单滚动监听 */
	function scroll(e) {
		//防抖
		globalProperties.$u.debounce(() => {
			console.log(e.detail.scrollTop);
			titleH.value.forEach((item, index) => {
				if ((e.detail.scrollTop + item.height) > item.top) {
					current.value = index
				}
			})
			scrollH.value = e.detail.scrollTop
		}, 100)

	}

3、加入购物车动画

购物车是固定的,我们得给它固定的id以便找到它

<view class="bottom">
			<view id="left_icon" class="left_icon" ref="cartBtn" @click="showPop = !showPop">
				<u-icon name="bag" size="80" color="#fff"></u-icon>
			</view>
			<view class="bottom_info">
				<view>共计:<text style="font-weight: bold;color: #FB3B26;">{{35}}</text>元</view>
				<view>已点:早餐、中餐、晚餐</view>
			</view>
			<view class="submit">
				确认预订
			</view>
		</view>
	</view>

定义移动小球的样式,写活它的初始位置

<!-- 小球 -->
	<view class="ball" v-if="showAnimation" :animation="animation"
		:style="{ top: ballTop + 'px', left: ballLeft + 'px' }">
	</view>
.ball {
		position: absolute;
		z-index: 1;
		width: 40rpx;
		height: 40rpx;
		background-color: red;
		border-radius: 50%;
	}

写活“+”号的id,以便我们获取实例

<view v-if="id" class="plus" :id="id" @click="addClick">
			<u-icon :name="plusIcon" size="32" color="#ffffff" :customStyle="iconStyle"></u-icon>
		</view>

 用uni.createAnimation()来制作动画,按钮的位置减去购物车的位置等于偏移的位置

/* 动画效果控制 */
	function addToCart(item) {
		const btn = '#id_' + item.id;
		const car = '.left_icon';
		console.log('#id_' + item.id);

		uni.createSelectorQuery().select(btn).boundingClientRect().exec((rect) => {
			const btnRect = rect[0];
			const left = btnRect.left;
			const top = btnRect.top;
			ballTop.value = top;
			ballLeft.value = left;
			uni.createSelectorQuery().select(car).boundingClientRect().exec((rect) => {
				console.log(rect);
				const carRect = rect[0];
				const x = carRect.left;
				const y = carRect.top;
				carTop.value = carRect.top;
				carLeft.value = carRect.left;
				animationData.value = uni.createAnimation()
				animationData.value.translate(x - left + 20, y - top).step({
					duration: 300,
				})
				animationTimeout.value
				clearTimeout(animationTimeout.value)
				animation.value = animationData.value.export()
				showAnimation.value = true;
				animationTimeout.value = setTimeout(() => {
					showAnimation.value = false;
				}, 300);
			});
		});
	}

4、代码

页面booking.vue

<template>
	<view class="booking">
		<view class="content">
			<view class="nav">
				<left-nav :data="list" :current="current" @change="navChange"></left-nav>
			</view>
			<scroll-view :scroll-into-view="toView" scroll-with-animation="true" class="main" @scroll="scroll" scroll-y>
				<view class="scroll_main">
					<view class="" v-for="(item,index) in list" :id="'type' + index">
						<view :id="'title' + index">
							<u-divider>{{item.meal_name}}</u-divider>
						</view>
						<card v-for="(item2,indax) in item.goods" :data="item2" @change="cardChange"></card>
					</view>
				</view>
			</scroll-view>
		</view>

		<view class="bottom">
			<view id="left_icon" class="left_icon" ref="cartBtn" @click="showPop = !showPop">
				<u-icon name="bag" size="80" color="#fff"></u-icon>
			</view>
			<view class="bottom_info">
				<view>共计:<text style="font-weight: bold;color: #FB3B26;">{{35}}</text>元</view>
				<view>已点:早餐、中餐、晚餐</view>
			</view>
			<view class="submit">
				确认预订
			</view>
		</view>
	</view>

	<!-- 弹出层 -->
	<u-popup v-model="showPop" mode="bottom" border-radius="20" closeable z-index="1">
		<scroll-view class="pop_main" scroll-y>
			<view class="pop_title">
				已选菜品
			</view>
			<view class="scroll_main">
				<view class="" v-for="(item,index) in list" :id="'type' + index">
					<view :id="'title' + index">
						<u-divider>{{item.meal_name}}</u-divider>
					</view>
					<card v-for="(item2,indax) in item.goods" :data="item2" @change="cardChange" :isAdd="false"></card>
				</view>
			</view>
		</scroll-view>
	</u-popup>

	<!-- 小球 -->
	<view class="ball" v-if="showAnimation" :animation="animation"
		:style="{ top: ballTop + 'px', left: ballLeft + 'px' }">
	</view>
</template>

<script setup>
	import leftNav from "@/components/booking/nav.vue"
	import card from "@/components/booking/card.vue"
	import {
		mockData
	} from "../binding/mock.js"
	import {
		getCurrentInstance,
		ref
	} from "vue";
	import {
		onLoad,
		onReady
	} from '@dcloudio/uni-app';
	onLoad(e => {
		mock.value = mockData
		list.value = mock.value.data.datas
		console.log(list.value);
	})
	onReady(() => {
		list.value.forEach((item, index) => {
			uni.createSelectorQuery().select('#title' + index).boundingClientRect(data => {
				console.log(data);
				titleH.value.push(data)
			}).exec()
		})
	})
	const showPop = ref(false)
	const animationData = ref()
	const animation = ref()
	const animationTimeout = ref()

	const titleH = ref([])

	const scrollH = ref(0)

	const toView = ref("")

	const current = ref(0)

	const mock = ref()

	const list = ref([{}])
	let ballTop = ref(0);
	let ballLeft = ref(0);
	let carTop = ref(0);
	let carLeft = ref(0);
	const showAnimation = ref(false);

	const {
		appContext: {
			app: {
				config: {
					globalProperties
				}
			}
		}
	} = getCurrentInstance()

	/* 菜单滚动监听 */
	function scroll(e) {
		//防抖
		globalProperties.$u.debounce(() => {
			console.log(e.detail.scrollTop);
			titleH.value.forEach((item, index) => {
				if ((e.detail.scrollTop + item.height) > item.top) {
					current.value = index
				}
			})
			scrollH.value = e.detail.scrollTop
		}, 100)

	}

	function cardChange(e) {
		addToCart(e)
	}

	function navChange(e) {
		current.value = e
		getRightScrollDistance()
	}

	function getRightScrollDistance() {
		toView.value = "title" + current.value;
	}

	/* 动画效果控制 */
	function addToCart(item) {
		const btn = '#id_' + item.id;
		const car = '.left_icon';
		console.log('#id_' + item.id);

		uni.createSelectorQuery().select(btn).boundingClientRect().exec((rect) => {
			const btnRect = rect[0];
			const left = btnRect.left;
			const top = btnRect.top;
			ballTop.value = top;
			ballLeft.value = left;
			uni.createSelectorQuery().select(car).boundingClientRect().exec((rect) => {
				console.log(rect);
				const carRect = rect[0];
				const x = carRect.left;
				const y = carRect.top;
				carTop.value = carRect.top;
				carLeft.value = carRect.left;
				animationData.value = uni.createAnimation()
				animationData.value.translate(x - left + 20, y - top).step({
					duration: 300,
				})
				animationTimeout.value
				clearTimeout(animationTimeout.value)
				animation.value = animationData.value.export()
				showAnimation.value = true;
				animationTimeout.value = setTimeout(() => {
					showAnimation.value = false;
				}, 300);
			});
		});
	}
</script>

<style lang="scss" scoped>
	page {
		background-color: #fff;
	}

	.content {
		min-height: 100vh;
		display: flex;

		.nav {
			flex: 1;
			min-width: 164rpx;
			background-color: #F6F6F6;
		}

		.main {
			flex: 3.5;
			height: 100vh;
			background-color: #fff;

			.scroll_main {
				padding-bottom: 150rpx;
			}
		}
	}


	.bottom {
		position: absolute;
		z-index: 2;
		bottom: 0;
		width: 750rpx;
		height: 132rpx;
		background: #FFFFFF;
		box-shadow: 0rpx -2rpx 16rpx 2rpx rgba(164, 164, 164, 0.11);
		border-radius: 0rpx 0rpx 0rpx 0rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;

		.bottom_info {
			flex: 1;
			margin: 0 20rpx;
			font-size: 26rpx;
			line-height: 40rpx;

			&>view:nth-child(2) {
				font-size: 24rpx;
				color: #aaa;
			}

		}

		.submit {
			color: #FFFFFF;
			padding: 10rpx 20rpx;
			background-color: #FB3B26;
			font-size: 26rpx;
			border-radius: 30rpx;
			margin-right: 50rpx;
		}

		#left_icon {
			margin-top: -30rpx;
			margin-left: 40rpx;
			width: 120rpx;
			height: 120rpx;
			background: #FB3B26;
			border-radius: 40rpx;
			line-height: 150rpx;
			text-align: center;
		}
	}

	.ball {
		position: absolute;
		z-index: 1;
		width: 40rpx;
		height: 40rpx;
		background-color: red;
		border-radius: 50%;
	}


	.pop_main {
		position: relative;
		max-height: 60vh;
		padding-top: 100rpx;
		padding-bottom: 150rpx;

		&>.pop_title {
			text-align: center;
			width: 100vw;
			height: 100rpx;
			font-size: 32rpx;
			font-weight: bold;
			position: fixed;
			top: 0;
			z-index: 1;
			background-color: #fff;
			line-height: 100rpx;
			text-align: center;
		}
	}
</style>

侧边栏组件nav.vue

<template>
	<view class="nav_main">
		<view v-for="(item,index) in data" :class="{'tool-box':true,'item':true,'item_act':current==index}"
			@click="change(index)">
			{{item.meal_name}}
		</view>
	</view>
</template>

<script setup>
	const emit = defineEmits(['change'])
	const props = defineProps({
		data: {
			type: Array,
			default: () => ([])
		},
		current: {
			type: Number,
			default: () => (0)
		},
	});

	function change(index) {
		emit('change', index) // 当前值 + 进步值
	}
</script>

<style scoped lang="scss">
	.nav_main {
		position: fixed;
	}

	.item {
		width: 164rpx;
		text-align: center;
		padding: 30rpx 0;
		font-size: 26rpx;
		color: #000000;
		font-weight: 400;
		position: relative;


	}

	.item_act {
		background-color: #fff;
		font-size: 26rpx;
		font-weight: 700;

		&::before {
			content: "";
			display: inline-block;
			width: 12rpx;
			height: 34rpx;
			background: #FC4E3E;
			border-radius: 0rpx 30rpx 30rpx 0rpx;
			position: absolute;
			left: 0;
		}
	}
</style>

商品卡片组件card.vue

<template>
	<view class="card_body">
		<view class="image">

		</view>
		<view class="foods_info">
			<view>{{data.name}}</view>
			<view></view>
			<view>
				<view class="">
					¥{{data.price}}
				</view>
				<counter v-if="isAdd" :id="'id_' + data.id" :number="data.number ?? 0" @change-click="change"></counter>
			</view>
		</view>
	</view>
</template>

<script setup>
	import counter from "@/components/booking/counter.vue"
	const emit = defineEmits(['change'])

	const props = defineProps({
		data: {
			type: Object,
			default: () => ({})
		},
		isAdd: {
			type: Boolean,
			default: () => true
		}
	});

	function change(e) {
		let obj = props.data
		obj.number = e
		console.log(obj);
		emit('change', obj)
	}
</script>

<style scoped lang="scss">
	.card_body {
		display: flex;
		margin: 30rpx 20rpx;

		.image {
			width: 180rpx;
			height: 180rpx;
			background-color: #a1a1a1;
			border-radius: 10rpx;
			margin-right: 20rpx;
		}

		.foods_info {
			display: flex;
			flex-direction: column;
			justify-content: space-between;
			flex: 1;

			&>view:nth-child(1) {
				font-weight: 700;
				font-size: 28rpx;
				color: #000000;
			}

			&>view:nth-child(3) {
				display: flex;
				align-items: center;
				font-weight: 400;
				font-size: 32rpx;
				color: #000000;
				justify-content: space-between;
			}
		}
	}
</style>

进步器组件counter.vue

<template>

	<view class="counter">
		<u-icon v-if="number>0" :name="reduceIcon" size="60" color="#8E8E8E" @click="reduceClick"></u-icon>
		<input v-if="number>0" type="number" :value="number" @blur="inputBlurEvent" @input="inputChangeEvent"
			:disabled="disabled">
		<view v-if="id" class="plus" :id="id" @click="addClick">
			<u-icon :name="plusIcon" size="32" color="#ffffff" :customStyle="iconStyle"></u-icon>
		</view>
	</view>
</template>

<script setup>
	import {
		ref,
		reactive,
		computed,
		nextTick
	} from "vue";
	const props = defineProps({
		id: {
			type: String,
			default: ""
		},
		disabled: {
			type: Number,
			default: false
		},
		number: {
			type: Number,
			default: 0
		},
		maxNumber: {
			type: Number,
			default: 99999
		},
		minNumber: {
			type: Number,
			default: 0
		},
		progressValue: {
			type: Number,
			default: 1
		},
		reduceIcon: {
			type: String,
			default: "minus-circle"
		},
		plusIcon: {
			type: String,
			default: "plus"
		}
	})
	const temp = computed(() => {
		return props.number
	})
	const iconStyle = reactive({
		fontWeight: 'blod'
	})
	const emit = defineEmits(['change-click'])
	// 加
	function addClick(ev) {
		emit('change-click', props.number + props.progressValue) // 当前值 + 进步值
	}
	// 减
	function reduceClick() {
		if (props.number <= props.minNumber) {
			console.log("不能继续减少啦 ~");
			return;
		}
		if ((props.number - props.progressValue) < props.minNumber) {
			console.log("不能继续减少");
			return;
		}
		// 3、执行 减操作
		emit('change-click', props.number - props.progressValue)
	}

	function inputBlurEvent(e) {
		let number = parseInt(e.detail.value)
		if (isNaN(number) || number === 0) {
			emit('change-click', 0)
			return;
		}


		// 条件:输入数不为进步值的倍数,则往前取成倍数值
		let multipie = Math.ceil(number / props.progressValue) // 获取倍数
		number = multipie * props.progressValue // 向上获取最近的倍数
		if (number > props.maxNumber) {
			number = props.maxNumber
			emit('change-click', number)
		} else if (number <= props.minNumber) {
			emit('change-click', props.minNumber)
		} else {
			emit('change-click', number)
		}
	}

	function inputChangeEvent(e) {
		// 限制输入在最大与最小值之间
		// 注意:因为都是赋值最大或最小值,所以会出现值复用无法重新渲染页面的情况(第一次能重新渲染,之后的都不渲染):已解决
		let number = parseInt(e.detail.value)
		if (isNaN(number) || number === 0) {
			// 为空为0
			return
		}
		if (number > props.maxNumber) {
			emit('change-click', props.maxNumber)
		} else if (number <= props.minNumber) {
			emit('change-click', props.minNumber)
		} else {
			emit('change-click', number)
		}
	}
</script>

<style lang="scss" scoped>
	.counter {
		display: flex;
		align-items: center;

		&>input {
			width: 2em;
			font-size: 28rpx;
			font-family: Source Han Sans CN-Bold, Source Han Sans CN;
			font-weight: bold;
			color: #000000;
			flex: 1;
			text-align: center;
		}

		.plus {
			margin: 8rpx;
			width: 48rpx;
			height: 48rpx;
			border-radius: 50%;
			background: #FF3232;

			display: flex;
			justify-content: center;
			align-items: center;

			&>image {
				width: 32rpx;
				height: 30rpx;
				margin-right: 5rpx;
			}
		}
	}
</style>

模拟数据mock.js

const mockData = {
	"code": 200,
	"msg": "",
	"data": {
		"datas": [{
				"meal_id": 5,
				"meal_name": "早餐",
				"meal_type": 1,
				"goods": [{
						"id": 4,
						"name": "牛奶",
						"price": "3.00",
						"img": ""
					},
					{
						"id": 5,
						"name": "馒头",
						"price": "2.00",
						"img": "http://192.168.1.23:9508/campus_pay_resource/goods/f82315767e959b536f64b0a199f99eb5.png"
					},
					{
						"id": 6,
						"name": "手抓饼",
						"price": "6.00",
						"img": "http://192.168.1.23:9508/campus_pay_resource/goods/9370838db9f50a2e950070995975e3b7.png"
					}
				]
			},
			{
				"meal_id": 5,
				"meal_name": "午餐",
				"meal_type": 1,
				"goods": [{
						"id": 7,
						"name": "牛奶",
						"price": "3.00",
						"img": ""
					},
					{
						"id": 8,
						"name": "牛奶",
						"price": "3.00",
						"img": ""
					},
					{
						"id": 9,
						"name": "牛奶",
						"price": "3.00",
						"img": ""
					},
					{
						"id": 10,
						"name": "牛奶",
						"price": "3.00",
						"img": ""
					},
					{
						"id": 11,
						"name": "牛奶",
						"price": "3.00",
						"img": ""
					},
					{
						"id": 12,
						"name": "牛奶",
						"price": "3.00",
						"img": ""
					},
					{
						"id": 13,
						"name": "牛奶",
						"price": "3.00",
						"img": ""
					},
					{
						"id": 14,
						"name": "牛奶",
						"price": "3.00",
						"img": ""
					},
					{
						"id": 15,
						"name": "牛奶",
						"price": "3.00",
						"img": ""
					},
					{
						"id": 16,
						"name": "牛奶",
						"price": "3.00",
						"img": ""
					},
					{
						"id": 17,
						"name": "牛奶",
						"price": "3.00",
						"img": ""
					},
					{
						"id": 18,
						"name": "牛奶",
						"price": "3.00",
						"img": ""
					},
					{
						"id": 19,
						"name": "馒头",
						"price": "2.00",
						"img": "http://192.168.1.23:9508/campus_pay_resource/goods/f82315767e959b536f64b0a199f99eb5.png"
					},
					{
						"id": 20,
						"name": "手抓饼",
						"price": "6.00",
						"img": "http://192.168.1.23:9508/campus_pay_resource/goods/9370838db9f50a2e950070995975e3b7.png"
					}
				]
			},
			{
				"meal_id": 5,
				"meal_name": "晚餐",
				"meal_type": 1,
				"goods": [{
						"id": 21,
						"name": "牛奶",
						"price": "3.00",
						"img": ""
					},
					{
						"id": 22,
						"name": "馒头",
						"price": "2.00",
						"img": "http://192.168.1.23:9508/campus_pay_resource/goods/f82315767e959b536f64b0a199f99eb5.png"
					},
					{
						"id": 23,
						"name": "手抓饼",
						"price": "6.00",
						"img": "http://192.168.1.23:9508/campus_pay_resource/goods/9370838db9f50a2e950070995975e3b7.png"
					}
				]
			},
			{
				"meal_id": 5,
				"meal_name": "宵夜",
				"meal_type": 1,
				"goods": [{
						"id": 24,
						"name": "牛奶",
						"price": "3.00",
						"img": ""
					},
					{
						"id": 25,
						"name": "馒头",
						"price": "2.00",
						"img": "http://192.168.1.23:9508/campus_pay_resource/goods/f82315767e959b536f64b0a199f99eb5.png"
					},
					{
						"id": 26,
						"name": "手抓饼",
						"price": "6.00",
						"img": "http://192.168.1.23:9508/campus_pay_resource/goods/9370838db9f50a2e950070995975e3b7.png"
					}
				]
			}
		],
		"school_name": "测试学校"
	}
}

export {
	mockData
}

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

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

【C++】封装哈希表 unordered_map和unordered_set容器

目录​​​​​​​ 一、unordered系列关联式容器 1、unordered_map 2、unordered_map的接口 3、unordered_set 二、哈希表的改造 三、哈希表的迭代器 1、const 迭代器 2、 operator 3、begin()/end() ​ 4、实现map[]运算符重载 四、封装 unordered_map 和 unordered_se…

基于t972 Android9 AP6256,如何在设置中添加5G热点选项,并使其正常打开

通过设置的的WiFi热点选项可以知道关键词“2.4GHz”&#xff0c;因此可以其全局搜索&#xff0c;在packages\apps\Settings\res\values\strings.xml文件下找到如下图所示&#xff0c; 从上面注释可以知道&#xff0c;选项按键选择2.4GHz触发的按键关键词是“wifi_ap_choose_2G…

JAVA读取从WPS在Excel中嵌入的图片资源

读取从WPS在Excel中嵌入的图片资源 引言 许多数据文件中可能包含嵌入式图片&#xff0c;这些图片对于数据分析和可视化非常重要。然而&#xff0c;从 WPS 在 Excel 中读取这些图片可能会有一些技术挑战。在本文中&#xff0c;我将展示如何从 WPS Excel 文件中读取嵌入的图片&am…

安居水站:心理咨询的一般伦理原则

正文字数&#xff1a; 1157 图片数&#xff1a; 24 阅读时间&#xff1a;大约4分钟 摘要&#xff1a;心理咨询是帮助个体解决心理问题的重要手段。为确保咨询的有效性和咨询对象的权益&#xff0c;心理咨询必须遵循一定的伦理原则。本文详细探讨了心理咨询…

PDF高效编辑器,支持修改PDF文档并转换格式从PDF文件转换成图片文件,轻松管理你的文档世界!

PDF文件已成为我们工作、学习和生活中不可或缺的一部分。然而&#xff0c;传统的PDF阅读器往往只能满足简单的查看需求&#xff0c;对于需要频繁编辑、修改或转换格式的用户来说&#xff0c;就显得力不从心。现在&#xff0c;我们为您带来一款全新的PDF高效编辑器&#xff0c;让…

对话访谈——五问RAG与搜索引擎:探索知识检索的未来

记一次关于RAG和搜索引擎在知识检索方面的对话访谈&#xff0c;针对 RAG 与传统搜索引擎的异同,以及它们在知识检索领域的优劣势进行了深入的探讨。 Q&#xff1a;传统搜索引擎吗&#xff0c;通过召回-排序的两阶段模式&#xff0c;实现搜索逻辑的实现&#xff0c;当前RAG技术也…

Spark Structured Streaming 分流或双写多表 / 多数据源(Multi Sinks / Writes)

博主历时三年精心创作的《大数据平台架构与原型实现&#xff1a;数据中台建设实战》一书现已由知名IT图书品牌电子工业出版社博文视点出版发行&#xff0c;点击《重磅推荐&#xff1a;建大数据平台太难了&#xff01;给我发个工程原型吧&#xff01;》了解图书详情&#xff0c;…

使用 scikit-learn 进行机器学习的基本原理-2

介绍 scikit-learn 估计器对象 每个算法都通过“Estimator”对象在 scikit-learn 中公开。 例如&#xff0c;线性回归是&#xff1a;sklearn.linear_model.LinearRegression 估计器参数&#xff1a;估计器的所有参数都可以在实例化时设置&#xff1a; 拟合数据 让我们用 nump…

第7篇:创建Nios II工程之控制LED<二>

Q&#xff1a;上一期我们完成了Quartus硬件工程部分&#xff0c;本期我们创建Nios II软件工程这部分。 A&#xff1a;创建完BSP和Nios II Application之后&#xff0c;在source文件main.c中添加LED控制代码&#xff1a;system.h头文件包含了Platform Designer系统中IP的硬件信…

VUE3----Tabs swiper 滑动切换

Tabs swiper 滑动切换 <template><view class"cc-tab-container"><scroll-view class"tab-head" :class"tabClassName" scroll-x"true" scroll-with-animation :scroll-left"state.scrollLeft"><view…

变电站综合自动化系统:Modbus-PLC-645转IEC104网关方案

前言 电力行业作为关系国计民生的重要基础产业&#xff0c;是关系千家万户的公用事业。但是要做好电力行业安全保障工作的前提&#xff0c;是需要对应的技术人员详细了解电力工业使用的系统、设备以及各类协议的安全特性&#xff0c;本文将主要介绍IEC 104协议的定义和钡铼技术…

STL——stackqueue

stack stack即为栈&#xff0c;先进后出是其特点 栈只有栈顶元素能被外界使用&#xff0c;故不存在遍历行为 栈中常用接口 构造函数 stack<T> stk; //默认构造方式 stack(const stack &stk); //拷贝构造 赋值操作 stack& operator(const stack &stk); …

对汉诺塔递归算法的简单理解

一.历史背景:汉诺塔&#xff08;Tower of Hanoi&#xff09;&#xff0c;又称河内塔&#xff0c;是一个源于印度古老传说的益智玩具。大梵天创造世界的时候做了三根金刚石柱子&#xff0c;在一根柱子上从下往上按照大小顺序摞着64片黄金圆盘。大梵天命令婆罗门把圆盘从下面开始…

网络安全是智能汽车下一个要卷的方向?

2024年一季度&#xff0c;中国汽车市场延续了2023年的风格&#xff0c;核心就是「卷」。 2023年&#xff0c;我国汽车市场爆发「最强价格战」&#xff0c;燃油车的市场空间不断被挤压&#xff0c;如今只剩下最后一口气。近日乘联会发布4月1-14日最新数据&#xff0c;新能源&am…

基于昇腾AI | 英码科技EA500I使用AscendCL实现垃圾分类和视频物体分类应用

现如今&#xff0c;人工智能迅猛发展&#xff0c;AI赋能产业发展的速度正在加快&#xff0c;“AI”的需求蜂拥而来&#xff0c;但AI应用快速落地的过程中仍存在很大的挑战&#xff1a;向下需要适配的硬件&#xff0c;向上需要完善的技术支持&#xff0c;两者缺一不可。 基于此&…

如何利用仪表构造InfiniBand流量在数据中心测试中的应用

一、什么是Infiniband&#xff1f; 在当今数据爆炸的时代&#xff0c;数据中心作为信息处理的中心枢纽&#xff0c;面临着前所未有的挑战。传统的通信方式已经难以满足日益增长的数据传输需求&#xff0c;而InfiniBand技术的出现&#xff0c;为数据中心带来了全新的通信解决方…

使用xshell工具连接ubuntu的root账户被拒绝的解决方法

问题描述&#xff1a; 我在使用xshell工具远程连接Ubuntu虚拟机的过程中&#xff0c;如果连接的是的普通用户则xshell工具可以正常连接&#xff0c;但是当我向连接ubuntu系统的root用户&#xff0c;即便是密码输入正确但还是不能连接成功。不能连接成功的截图如下&#xff1a; …

requests库进行接口请求

请求的常规写法 requests.post() 、requests.get() 从中可以看出&#xff1a; 必填参数&#xff1a; url可缺省参数&#xff1a; data&#xff0c;json等、关键字参数 **kwargs 如下进行了一个post请求的登录&#xff0c;且请求体在body中 知识点1 当为post请求时&#xff1…

建堆时间复杂度

片头 嗨&#xff01;小伙伴们&#xff0c;大家好&#xff01; 在上一篇中&#xff0c;我们学习了什么是堆&#xff0c;以及如何实现堆。这一篇中&#xff0c;我将继续带领大家来深入学习堆&#xff0c;准备好了吗&#xff1f;我要开始咯&#xff01; 首先&#xff0c;大家还记…

opencv_17_翻转与旋转

一、图像翻转 1&#xff09;void flip_test(Mat& image); 2&#xff09;void ColorInvert::flip_test(Mat& image) { Mat dst; //flip(image, dst, 0); //上下翻转 flip(image, dst, 1); //左右翻转 // flip(image, dst, -1); //180度翻转 imsho…