【微信小程序封装底部弹出框一】
<!--index.wxml-->
<view>
<button style="margin-top: 300px;" catchtap="changeRange2">点击唤起弹窗222</button>
<!-- 弹框 -->
<dialogA id='dialog' catchtouchmove="preventTouchMove" bind:customEventHandler="customEvent"></dialogA>
</view>
{
"usingComponents": {
"dialogA":"/components/dialogA/dialog",
"dialog":"/components/dialog/dialog"
}
}
// index.js
// 获取应用实例
const app = getApp()
Page({
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
this.popup = this.selectComponent("#dialog"); //获取
},
// 调用子组件事件---弹窗2
changeRange2(e) {
var _this = this;
_this.popup.changeRange(); //调用子组件内的函数
},
})
<!--components/dialog/dialog.wxml-->
<view class="half-screen" catchtouchmove="preventTouchMove">
<!--屏幕背景变暗的背景 -->
<view class="background_screen" catchtap="hideModal" wx:if="{
{showModalStatus}}"></view>
<!--弹出框 -->
<view animation="{
{animationData}}" class="attr_box" wx:if="{
{showModalStatus}}">
<view class="dialog-box">
<view class="dialog-head">