微信小程序静态模框

效果图

在这里插入图片描述
实现代码

<view class="mask" catchtouchmove="preventTouchMove" wx:if="{{showModal}}"></view>

<view class="modalDlg" wx:if="{{showModal}}">
    <text>欢迎来到模态对话框~</text>
    <button bindtap="go">确认</button>
    <button bindtap="no">取消</button>
</view>

<button bindtap="submit">{{btnName}}</button>
.mask{
    width: 100%;
    height: 100%;
    position: fixed;
    top: 0;
    left: 0;
    background: #000;
    z-index: 9000;
    opacity: 0.7;
}

.modalDlg{
    width: 580rpx;
    height: 620rpx;
    position: fixed;
    top: 50%;
    left: 0;
    z-index: 9999;
    margin: -370rpx 85rpx;
    background-color: #fff;
    border-radius: 36rpx;
    display: flex;
    flex-direction: column;
    align-items: center;
}


data: {
        showModal: false,
        btnName: "点我弹窗",
    },

   go: function () {
        this.setData({
            showModal: false,
            btnName: "点击了确认"
        })
    },

    no: function () {
        this.setData({
            showModal: false,
            btnName: "点击了取消"
        })
    },
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是一个简单的微信小程序静态页面的源码,包括一个简单的页面布局和两个按钮: ```html <view class="container"> <view class="header"> <text class="title">欢迎来到微信小程序</text> </view> <view class="content"> <text>这是一个简单的静态页面</text> <button class="btn">按钮1</button> <button class="btn">按钮2</button> </view> </view> ``` 在这个页面中,我们有一个包含所有内容的容器 view,一个标题栏 header 和一个内容区域 content。内容区域包含一些文本和两个按钮。我们使用 class 属性来给不同的元素定义样式。 接下来,我们需要在微信小程序的开发工具中创建一个新的页面,并将这段代码复制到 wxml 文件中。然后,我们可以使用 wxss 文件来为页面添加样式。 ```css .container { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100vh; background-color: #f5f5f5; } .header { display: flex; align-items: center; justify-content: center; height: 80rpx; width: 100%; background-color: #007aff; } .title { color: #fff; font-size: 32rpx; } .content { display: flex; flex-direction: column; align-items: center; justify-content: center; } .btn { margin-top: 40rpx; width: 280rpx; height: 80rpx; background-color: #007aff; color: #fff; font-size: 32rpx; border-radius: 10rpx; } ``` 在这个样式中,我们使用了 flexbox 布局来实现页面的垂直居中和内容区域的布局。我们还使用了一些常见的 CSS 属性,如颜色、字体大小和边框半径。 最后,我们需要在小程序的 pages.json 文件中注册这个新页面: ```json { "pages": [ { "path": "pages/index/index", "navigationBarTitleText": "首页" } ], "window": { "backgroundTextStyle": "light", "navigationBarBackgroundColor": "#007aff", "navigationBarTitleText": "微信小程序", "navigationBarTextStyle": "white" }, "tabBar": { "list": [ { "pagePath": "pages/index/index", "text": "首页" }, { "pagePath": "pages/logs/logs", "text": "日志" } ] } } ``` 现在,我们就可以在微信小程序中查看这个新页面了。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值