uniapp的底部弹出层实现保姆式教程

实现照片:

此过程先进入uniapp官网,找到扩展组件

打开找到里面的uni-popup和uni-icons

点击进入,下载&安装

点击下载并导入HBuilderX

导入到你使用的目录,如test目录

同样将uni-icons点击下载并导入HBuilderX

点击合并

此时test文件夹下多了一个uni-modules文件夹

在pages下的index.vue内编写代码,如下:

html 复制代码
<template>
	<view>
		<button @click="open">打开弹窗</button>
		<uni-popup ref="popup" type="bottom" background-color="#fff" border-radius="10px 10px 0 0" :show="true" @close="closePopup">
			<view style="border-bottom: 1rpx solid #E5E5E5;padding:24rpx 0 32rpx; text-align: center;">提示</view>
				<view class="flex-colomn">
						<view class="tet">正确答案为:{{answer}}</view>
						<uni-icons class="close-btn" type="closeempty" size="20" @click="closePopup"></uni-icons>
				</view>
		</uni-popup>
	</view>
</template>
<script>
export default {
	data() {
	  return {
	    answer: 'A',
		
			}
		},
   methods:{
      open(){
        // 通过组件定义的ref调用uni-popup方法 ,如果传入参数 ,type 属性将失效 ,仅支持 ['top','left','bottom','right','center']
		
        this.$refs.popup.open('bottom')
      },
	  
	  closePopup() {
		  this.$refs.popup.close()
	  },
   }
}
</script>


 
<style>
.tet {
	display: flex;
	justify-content: center;
	align-items: flex-start;
	height: 45vh;
	font-size: 25px;
	margin-top: 20rpx;
}
.close-btn {
    position: absolute;
    top: 20rpx;
    right: 20rpx;
    cursor: pointer;

  }

</style>

里面代码官网都有解释,获得底部弹出效果。

相关推荐
一份执念1 天前
uni-app项目 (vue+vite + uni-UI)中引入umd格式JS文件,微信小程序中导入报错处理方案
前端·uni-app·echarts
PedroQue991 天前
V1.6.1性能优化:高频路径提速与代码精简
前端·uni-app
夏碧笔3 天前
uni-app跨端地图实战:用第三方LBS替代微信平台收费服务
uni-app
用户6990304848758 天前
try catch使用场景 处理同步代码错误兼容用的
javascript·uni-app
ITKEY_8 天前
uniapp微信开发者工具 更改AppID失败 touristappid
uni-app
Geek_Vison8 天前
APP瘦身实战:从80MB+砍到15MB——基于小程序容器技术剥离APP非核心业务的实践分享
小程序·uni-app·mpaas
CHB9 天前
HDC2026 演讲实录|AI 驱动的跨端进化:利用 uni-agent 快速构建高性能鸿蒙应用
uni-app·harmonyos
2501_915918419 天前
iOS App性能测试工具的实现方法与优化循环指南
android·ios·小程序·https·uni-app·iphone·webview
斯内普吖9 天前
(开源)高校素拓分管理系统小程序实战指南 基于 Java + SpringBoot + uni-app + Vue + MySQL
java·spring boot·mysql·小程序·uni-app·开源
海阔天空66889 天前
uniapp开启调试模式
uni-app·uniapp开启调试模式