【css】前端根据(html)Dom传参给css

【需求描述】

1.需要动态的从后端获取文件进行渲染
2. 获取后端域名要求加密解析

【解决方案】

说白了也就是CSS中的变量使用——var() 函数用于动态改变url

<view class="Judicial_f" :style="{ '--j': Judicial, '--j1': Judicial1, '--j2': Judicial2 }">
// script 如下
data() {
			return {
				Judicial: "url(" + this.$getPicture("attachment/picture/home/ui/Judicial-l.png") + ")",
				Judicial1: "url(" + this.$getPicture("attachment/picture/home/ui/Judicial-r-t.png") + ")",
				Judicial2: "url(" + this.$getPicture("attachment/picture/home/ui/Judicial-r-b.png") + ")",
				list: [],
				list1: [],
				DataTitle: "",
				mode: "dot",
			};
		},

这里的this.$getPicture这个是全局获取baseURL的方法

// main.js
/**
 * 获取图片url
 */
Vue.prototype.$getPicture = function (value) {
  const url = uni.$u.http.config.baseURL + value
  return url
};

在这里插入图片描述

完整代码如下:

<template>
	<view class="top1">
		<view class="home-body">

			<!-- 司法鉴定 -->
			<view class="Judicial">
				<view class="Judicial_t">
					<img style="padding-right: 10px" class="Health_img"
						:src="this.$getPicture('attachment/picture/home/ui/title-icon.png')" />
					<span style="font-size: 20px; font-weight: 600">司法鉴定</span>
				</view>
				<view class="Judicial_f" :style="{ '--j': Judicial, '--j1': Judicial1, '--j2': Judicial2 }">
					<view class="Judicial_f-left" style="width: 48%" @click="goJudge(0)">
						<view class="J-text">
							<span style="font-size: 15px; font-weight: 600">鉴定咨询</span>
							<span style="font-size: 10px; color: #999">Appraisal consultati</span>
						</view>
					</view>
					<view class="Judicial_f-right" style="width: 48%">
						<view class="Jr-t" @click="goJudge(1)">
							<view class="J-text">
								<span style="font-size: 15px; font-weight: 600">预约鉴定</span>
								<span style="font-size: 0.35rem; color: #999">Appraisal consultati</span>
							</view>
						</view>
						<view class="Jr-b" @click="goJudge(2)">
							<view class="J-text">
								<span style="font-size: 15px; font-weight: 600">法医鉴定</span>
								<span style="font-size: 0.35rem; color: #999">Appraisal consultati</span>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getTitle,
		banner,
		indexGoodsList
	} from "../../api/home.js";

	export default {
		onPullDownRefresh: function() {
			//下拉刷新的时候请求一次数据
			this.getTitle();
		},
		data() {
			return {
				Judicial: "url(" + this.$getPicture("attachment/picture/home/ui/Judicial-l.png") + ")",
				Judicial1: "url(" + this.$getPicture("attachment/picture/home/ui/Judicial-r-t.png") + ")",
				Judicial2: "url(" + this.$getPicture("attachment/picture/home/ui/Judicial-r-b.png") + ")",
				list: [],
				list1: [],
				DataTitle: "",
				mode: "dot",
			};
		},
		
	};
</script>

<style lang="scss" scoped>
	.top1 {
		height: 100%;
		overflow: auto;
		padding-bottom: 1rem;
	}

	.home-title {
		position: absolute;
		left: 5%;
		top: 75px;
		font-size: 20px;
		font-weight: 500;
		color: rgba(255, 255, 255, 1);
		opacity: 0.9;
		text-shadow: 0px 2px 10px rgba(33, 165, 191, 0.1);
		z-index: 1;
		width: 90%;
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.home-title .iconfont {
		font-size: 15px;
	}

	.ad-image {
		position: absolute;
		width: 94%;
		height: 2.75rem;
		left: 3%;
		top: 115px;
		z-index: 1;
	}

	@mixin H-background($url) {
		width: 48%;
		background: url($url) no-repeat right 14px;
		background-size: 100%;
		height: 2rem;
		text-align: left;

		span {
			position: relative;
			top: 40%;
			left: 12%;
			font-size: 15px;
			font-weight: 600;
		}
	}

	@mixin H-Judicial($url, $h) {
		background: $url no-repeat right;
		background-size: 100%;
		height: $h;
		text-align: left;
	}

	.heads {
		height: 250px;
	}

	.head-img {
		position: relative;
		width: 100%;
		height: 210px;
		top: 0px;
		z-index: 0;
	}

	.img-header {
		width: 100%;
		height: 100%;
	}

	.Health {
		margin: 10px 15px;
		background: #ffffff;
		border-radius: 10px;
		padding: 15px;

		&_t {
			display: flex;
			align-items: center;
		}

		&_img {
			width: 25rpx;
			height: 25rpx;
		}

		&_f {
			display: grid;
			grid-gap: 10px;

			.hf-button {
				display: flex;
				flex-direction: column;
				align-items: center;
				margin: 15px 0px;

				span {
					font-weight: 600;
					font-size: 15px;
					padding-top: 0.2rem;
				}

				img {
					width: 50px;
					height: 50px;
				}
			}
		}
	}

	.Judicial {
		margin: 10px 15px;
		background: #ffffff;
		border-radius: 10px;
		padding: 15px;

		&_t {
			display: flex;
			align-items: center;
		}

		&_f {
			display: flex;
			justify-content: space-between;
			margin-top: 15px;

			.J-text {
				display: flex;
				flex-direction: column;
				position: relative;
				top: 20%;
				left: 10%;
			}

			&-left {
				@include H-Judicial(var(--j), 170px);
			}

			&-right {
				display: flex;
				flex-direction: column;
				justify-content: space-between;

				.Jr-t {
					@include H-Judicial(var(--j1), 85px);
				}

				.Jr-b {
					@include H-Judicial(var(--j2), 85px);
				}
			}
		}
	}

	.HealthyMall {
		margin: 10px 15px;
		background: #ffffff;
		border-radius: 10px;
		padding: 15px;

		&_t {
			display: flex;
			justify-content: space-between;

			.Ht1 {
				display: flex;
				align-items: center;
			}

			.Ht2 {
				@extend .Ht1;
			}
		}

		.el-card {
			border: 0 solid #ebeef5;
		}

		.images {
			width: 2.6rem;
			height: 2.6rem;
		}

		.HS-list {
			margin-top: 15px;
		}

		.scroll-list {
			@include flex(column);

			&__goods-item {
				margin-right: 20px;

				&__image {
					width: 80px;
					height: 80px;
					border-radius: 4px;
				}

				&__text {
					color: #f56c6c;
					text-align: center;
					font-size: 15px;
					margin-top: 5px;
				}
			}

			&__show-more {
				background-color: #fff0f0;
				border-radius: 3px;
				padding: 3px 6px;
				@include flex(column);
				align-items: center;

				&__text {
					font-size: 12px;
					width: 12px;
					color: #f56c6c;
					line-height: 16px;
				}
			}
		}
	}
</style>

完结~

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: HTML CSS前端智慧校园系统网页源码,是指使用HTMLCSS语言编写的前端代码,用于创建一个智慧校园系统的网页。智慧校园系统是利用计算机和互联网技术,为学校提供信息化管理和服务的一种综合性平台。 网页源码主要包括HTMLCSS代码,HTML负责页面结构的搭建,CSS则负责页面样式的设计和布局。 在HTML代码中,可以使用不同的标签来创建网页的各个部分,比如头部导航栏、侧边栏、主要内容区域等。使用标签可以实现页面的划分和布局,方便用户进行浏览和操作。 而CSS样式代码则用于美化页面,通过定义不同的样式属性和值,可以设置网页中的文本字体、颜色、背景、边框等,从而使得网页具有更好的视觉效果。 在具体实现智慧校园系统网页的过程中,可以根据需求进行定制化开发,比如添加学生课程表、成绩查询、教师和学生信息管理等功能。通过将这些功能模块与HTMLCSS代码结合起来,可以实现一个全面而且美观的智慧校园系统网页。 总的来说,HTML CSS前端智慧校园系统网页源码是一个用于创建智慧校园系统网页的前端代码,通过HTMLCSS的结合,可以实现网页的布局和样式设计,为学校提供全面且美观的信息化管理和服务。 ### 回答2: HTML CSS前端智慧校园系统网页源码是用HTMLCSS编写的智慧校园系统的前端网页界面代码。该系统是基于Web的校园管理系统,在网页上实现了课程管理、学生成绩查看、作业提交、通知公告等功能。 HTML是用来定义网页结构的标记语言,它提供了丰富的元素和属性,用于构建网页的内容和布局。在智慧校园系统中,HTML被用来创建各种功能模块的网页元素,如导航栏、课程列表、成绩表等。通过使用不同的HTML元素和属性,可以实现不同功能的网页界面。 CSS是用来控制网页样式的样式表语言,它可以定义网页中元素的外观和布局。在智慧校园系统中,CSS被用来设置元素的颜色、字体、大小、边距等样式属性,以及调整元素的位置和布局。通过使用不同的CSS样式规则,可以使网页界面更加美观、易读和易用。 智慧校园系统的前端网页源码会包含HTMLCSS的代码,通过嵌套、引用和调用,将不同的功能模块组合起来,形成完整的网页界面。开发者需要根据系统需求和设计要求,编写对应的HTMLCSS代码,实现各种功能和效果。通过合理使用HTMLCSS的特性和技巧,还可以优化用户体验,提高系统的性能和响应速度。 综上所述,HTML CSS前端智慧校园系统网页源码是基于HTMLCSS的智慧校园系统的前端网页界面代码,通过编写和调整HTMLCSS代码,实现各种功能和样式效果,提供用户友好的界面和良好的用户体验。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值