第4讲 小程序首页实现

首页 create.vue

bash 复制代码
<template>
	<view class="vote_type">
		<view class="vote_tip_wrap">
			<text class="type_tip">请选择投票类型</text>
			<!-- <text class="share">&#xe739;分享给朋友</text> -->
		</view>
		<view class="type_list">
			<view class="type_item" @click="goWordVote()">
				<view class="type_item_log_word"/>
				<view class="type_item-body">
					<view class="type_item-text-top">文字投票</view>
					<view class="type_item-text-bottom">
						选项为纯文字,使用方便,简单快捷
					</view>
				</view>
			</view>
			<view class="type_item" @click="goPicVote()">
				<view class="type_item_log_pic"/>
				<view class="type_item-body">
					<view class="type_item-text-top">图文投票</view>
					<view class="type_item-text-bottom">
						选项为纯图片,可以上传图片作品进行投票
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default{
		data(){
			return{
				
			}
		},
		methods:{
			goWordVote:function(){
				uni.navigateTo({
					url:"/pages/createWordVote/createWordVote"
				})
			},
			goPicVote:function(){
				uni.navigateTo({
					url:"/pages/createPicVote/createPicVote"
				})
			}
		}
	}
</script>

<style lang="scss">

	.vote_type{
		padding: 20px;
		.vote_tip_wrap{
			.type_tip{
				font-size: 26rpx;
				color: gray;
			}
		}
		
		.type_list{
			margin-top: 10px;
			.type_item{
				border-radius: 5px;
				background-color: white;
				display: flex;
				width: 100%;
				flex-direction: row;
				margin-bottom: 15px;
				.type_item_log_word{
					background: url("../../static/image/word.png") no-repeat center;
					width: 3.0rem;
					height: 3.0rem;
					margin-right: 0.425rem;
					background-size:cover;
					margin: 30rpx;
				}
				.type_item_log_pic{
					background: url("../../static/image/pic.png") no-repeat center;
					width: 3.0rem;
					height: 3.0rem;
					margin-right: 0.425rem;
					background-size:cover;
					margin: 30rpx;
				}
				.type_item-body{
					height: auto;
					display: flex;
					flex: 1;
					flex-direction: column;
					justify-content: space-around;
					align-items: flex-start;
					overflow: hidden;
					.type_item-text-top{
					
						font-size: 1.15rem;
						overflow: hidden;
						width: 100%;
						
						font-weight: bolder;
						padding-top: 10px;
					}
					.type_item-text-bottom{
						display: flex;
						flex-direction: row;
						justify-content: space-between;
						width: 100%;
						line-height: 0.9375rem;
						font-size: 0.7125rem;
						color: #8f8f94;
						padding-bottom: 15rpx;
					}
				}
			}
		}
	}
</style>

设置公共的背景色App.vue里面

bash 复制代码
	/*每个页面公共css */
	body,page{
		background-color: #f4f5f7;
	}

创建createWordVote和createPicVote两个页面

bash 复制代码
,
		{
			"path": "pages/createWordVote/createWordVote",
			"style": {
				"navigationBarTitleText": "创建文字投票"
			}
		},
		{
			"path": "pages/createPicVote/createPicVote",
			"style": {
				"navigationBarTitleText": "创建图文投票"
			}
		}

图片路径

相关推荐
h_65432108 小时前
微信小程序点击按钮跳转链接并显示
微信小程序·小程序
银迢迢11 小时前
微信小程序的开发及问题解决
微信小程序·小程序
liyinchi198811 小时前
原生微信小程序 textarea组件placeholder无法换行的问题解决办法
微信小程序·小程序
说私域13 小时前
基于开源链动2+1模式AI智能名片S2B2C商城小程序的低集中度市场运营策略研究
人工智能·小程序·开源·零售
少恭写代码16 小时前
duxapp 2025-03-29 更新 编译结束的复制逻辑等
react native·小程序·taro
suncentwl17 小时前
答题pk小程序道具卡的获取与应用
小程序·答题小程序·知识竞赛
bysjlwdx18 小时前
uniapp婚纱预约小程序
小程序·uni-app
ALLSectorSorft18 小时前
代驾小程序订单系统框架搭建
小程序·代驾小程序
qq_124987075318 小时前
原生小程序+springboot+vue+协同过滤算法的音乐推荐系统(源码+论文+讲解+安装+部署+调试)
java·spring boot·后端·小程序·毕业设计·课程设计·协同过滤
前端极客探险家1 天前
微信小程序全解析:从入门到实战
微信小程序·小程序