当前位置:网站首页>Wechat applet custom pop-up components
Wechat applet custom pop-up components
2022-06-26 18:41:00 【RosaChampagne】
design sketch :

<!--components/popup/popup.wxml-->
<view class="popup" hidden="{
{flag}}">
<view class='popup-container'>
<view wx:if="{
{title}}" class="popup-title">{
{title}}</view>
<view>
</view>
<view class="popup-con">
<image src="{
{image}}" />
<view>{
{content}}</view>
</view>
<view class="popup-btn">
<text class="btn-no" bindtap='_error'>{
{btn_no}}</text>
<text class="btn-ok" bindtap='_success'>{
{btn_ok}}</text>
</view>
</view>
</view>// components/popup/popup.js
Component({
/**
* Component properties
*/
properties: {
title: { // Property name
type: String, // type ( Required ), The current types of acceptance include :String, Number, Boolean, Object, Array, null( Represents any type of )
value: '' // Property initial value ( Optional ), If it is not specified, it will select one... According to the type
},
// Pop up picture
image: {
type: String,
value: ''
},
// Pop-up content
content: {
type: String,
value: ''
},
// Pop up cancel button text
btn_no: {
type: String,
value: ' Cancel '
},
// Pop up confirmation button text
btn_ok: {
type: String,
value: ' determine '
}
},
/**
* Component initial data
*/
data: {
flag: true,
},
/**
* Component methods
*/
methods: {
// Hide the bullet box
hidePopup: function () {
this.setData({
flag: !this.data.flag
})
},
// Display bullet frame
showPopup () {
this.setData({
flag: !this.data.flag
})
},
/*
* Internal private methods recommend starting with a dash
* triggerEvent Used to trigger events
*/
_error () {
// Trigger cancel callback
this.triggerEvent("error")
},
_success () {
// Trigger successful callback
this.triggerEvent("success");
}
}
})
{
"component": true
}/* components/popup/popup.wxss */
.popup {
z-index: 9;
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, .5);
}
.popup-container {
position: absolute;
left: 50%;
top: 50%;
width: 80%;
max-width: 600rpx;
border: 2rpx solid #ccc;
border-radius: 20rpx;
box-sizing: bordre-box;
transform: translate(-50%, -50%);
overflow: hidden;
background: rgba(250,250,250,1);
}
.popup-title {
width: 100%;
padding: 20rpx;
text-align: center;
font-size: 40rpx;
border-bottom: 2rpx solid red;
}
.popup-con {
margin: 36rpx 10rpx;
text-align: center;
}
.popup-con image {
width: 196rpx;
height: 196rpx;
}
.popup-btn {
display: flex;
justify-content: space-around;
}
.popup-btn text {
display: flex;
align-items: center;
justify-content: center;
width: 50%;
height: 106rpx;
border-top: 2rpx solid #EDEDED;
}
.popup-btn .btn-no {
border-right: 2rpx solid #EDEDED;
} <popup id='popup'
image='../../images/organizer/application-success.png'
content=' Successful application '
btn_no=' Start the campaign now '
btn_ok=' Become an authenticated user '
bind:error="_error"
bind:success="_success">
</popup>
onReady: function (options) {
// get popup Components
this.popup = this.selectComponent("#popup");
},
showPopup() {
this.popup.showPopup();
},
// Cancel event
_error() {
console.log(' You click Cancel ');
this.popup.hidePopup();
},
// Confirm event
_success() {
console.log(' You click OK ');
this.popup.hidePopup();
},
边栏推荐
- 一些基本错误
- ros::spinOnce()和ros::spin()的使用和区别
- Eigen库计算两个向量夹角
- Feign remote call
- CLion断点单步调试
- Conditional compilation in precompiling instructions
- Project practice 5: build elk log collection system
- 利用递归实现求n位所有格雷码
- MySQL download and configuration MySQL remote control
- To: Apple CEO Cook: great ideas come from constantly rejecting the status quo
猜你喜欢

Clion breakpoint single step debugging

Project practice 4: user login and token access verification (reids+jwt)

(树) 树状数组

Boyun, standing at the forefront of China's container industry

成功解决之idea引用Lombok的@Slf4j后无法正常使用log

SSO微服务工程中用户行为日志的记录

(必须掌握的多线程知识点)认识线程,创建线程,使用Thread的常见方法及属性,以及线程的状态和状态转移的意义

Vscode 基础必备 常用插件

Crawl Douban to read top250 and import it into SqList database (or excel table)

When does the mobile phone video roll off?
随机推荐
(必须掌握的多线程知识点)认识线程,创建线程,使用Thread的常见方法及属性,以及线程的状态和状态转移的意义
Enter n integers and output the number of occurrences greater than or equal to half the length of the array
你了解如何比较两个对象吗
SSO微服务工程中用户行为日志的记录
CLion断点单步调试
JVM入个门(1)
爬取豆瓣读书Top250,导入sqlist数据库(或excel表格)中
Pinda general permission system (day 1~day 2)
判断某个序列是否为栈的弹出序列
微服务版单点登陆系统(SSO)
物联网协议的王者:MQTT
Refresh the strong pointer assignment problem in the HP-UX system of Sanguan
NFTGameFi链游系统开发详解方案丨链游系统开发原理解析
To: seek truth from facts
JVM entry door (1)
LeetCode 238 除自身以外数组的乘积
DAPP丨LP单双币流动性质押挖矿系统开发原理分析及源码
Jsonutils tool class (based on Alibaba fastjson)
为什么我不推荐去SAP培训机构参加培训?
利用递归实现求n位所有格雷码