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>

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

相关推荐
2501_9159184110 小时前
iOS App 测试方法,Xcode、TestFlight与克魔(KeyMob)等工具组合使用
android·macos·ios·小程序·uni-app·iphone·xcode
2501_9159214311 小时前
iOS 描述文件制作过程,从 Bundle ID、证书、设备到描述文件生成后的验证
android·ios·小程序·https·uni-app·iphone·webview
2501_915909061 天前
如何保护 iOS IPA 文件中资源与文件的安全,图片、JSON重命名
android·ios·小程序·uni-app·json·iphone·webview
2501_915909061 天前
原生与 H5 共存情况下的测试思路,混合开发 App 的实际测试场景
android·ios·小程序·https·uni-app·iphone·webview
游戏开发爱好者81 天前
了解 Xcode 在 iOS 开发中的作用和功能有哪些
android·ios·小程序·https·uni-app·iphone·webview
2501_915106322 天前
iOS 抓包工具实战实践指南,围绕代理抓包、数据流抓包和拦截器等常见工具
android·ios·小程序·https·uni-app·iphone·webview
Jyywww1212 天前
Uniapp+Vue3 移动端顶部安全距离
uni-app
2501_915106322 天前
如何在 iOS 设备上理解和分析 CPU 使用率(windows环境)
android·ios·小程序·https·uni-app·iphone·webview
怀君2 天前
Uniapp——苹果IOS离线打自定义基座教程
ios·uni-app
码农客栈2 天前
小程序学习(十二)之命令行创建uni-app项目
学习·小程序·uni-app