


Mini program development to create pop-up menu function (with code)
Jun 13, 2018 pm 01:47 PMThis time I will bring you the pop-up menu function of mini program development (with code). What are the precautions for mini program development of pop-up menu function? The following is a practical case, let’s take a look.
Requirements
Click the tab bar button to pop up the menu, click again to retract the menu
Problems to be solved
Tab bar three-column style, the tab bar is fixed;
Click the tab bar to pop up the menu, and a transparent mask appears;
The mask priority is under the pop-up box;
Setting the label in the pop-up box;
Hide the scroll bar of the scroll bar
How to solve it?
Flexible layout, horizontal, the three equally divide the entire column;
State monitoring click event, data control hide or show, through rgba Set transparency
Set z-index for the pop-up box;
-
Elastic layout flex wrap after horizontal arrangement exceeds then space-around control spacing
::-webkit-scrollbar?{ width:?0; height:?0; color:?transparent; }
Specific implementation
wxml
<import src="../../templates/template" /> <view class="container {{isMask?'mask':''}}"> ??<view class="header"> ????<view class="filterCity {{status=='1' && isActive?'active':''}}" data-status='1' bindtap="changeStatus"> ??????<view class="city">城市篩選</view> ??????<image src="{{status=='1' && isActive?'../../youzan-image/red-up.png':'../../youzan-image/down.png'}}" /> ????</view> ????<view class="filterJob {{status=='2' && isActive?'active':''}}" data-status='2' bindtap="changeStatus"> ??????<view class="job">職位篩選</view> ??????<image src="{{status=='2' && isActive?'../../youzan-image/red-up.png':'../../youzan-image/down.png'}}" /> ????</view> ????<view class="filterOrder {{status=='3'&& isActive?'active':''}}" data-status='3' bindtap="changeStatus"> ??????<view class="order">排序方式</view> ??????<image src="{{status=='3' && isActive?'../../youzan-image/red-up.png':'../../youzan-image/down.png'}}" /> ????</view> ??</view> ??<block wx:if="{{isActive==true&&status=='1'}}"> ????<view class="cityContainer"> ??????<block wx:for="{{city}}" wx:key="id" wx:for-index="index"> ????????<view class="city {{isSelect&&index==curIndex?'select':''}}" data-index="{{index}}" bindtap="select">{{item}}</view> ??????</block> ????</view> ??</block> ??<block wx:if="{{isActive==true&&status=='2'}}"> ????<scroll-view scroll-y="true" class="posContainer"> ??????<block wx:for="{{cur}}" data-index='index' wx:for-index='index' wx:key="index"> ????????<view class="title">{{item.title}}</view> ????????<view class="poscontent"> ??????????<view wx:for="{{item.types}}" wx:for-item="type" wx:key='id' wx:for-index="{{index}}" data-index="{{index}}"> ????????????<view class="tag {{isSelect&&index==curIndex?'select':''}}" data-id="{{id}}" bindtap="multiSelect">{{type}}</view> ??????????</view> ????????</view> ??????</block> ??????<view class="confirm"> ????????<button class="weui-btn" type="warn">確認</button> ??????</view> ????</scroll-view> ??</block> ??<block wx:if="{{isActive==true&&status=='3'}}"> ????<view class="orderContainer"> ??????<view class="block">智能排序</view> ??????<view class="block">時間排序</view> ??????<view class="block">薪資排序</view> ????</view> ??</block> ??<view class="listContainer" > ????<view wx:for="{{jobList}}" wx:key="index" data-index="{{index}}"> ??????<template is="list-item" data="{{...item}}" /> ????</view> ??</view> ??<view class="search " bindtap="search"> ????<image src="../../youzan-image/search.png" /> ????<text>搜索</text> ??</view> </view>
wxss
page?{ ??position:?relative; ??width:?100%; ??height:?100vh; } .header?{ ??width:?100%; ??height:?80rpx; ??position:?fixed; ??top:?0; ??display:?flex; ??flex-direction:?row; ??justify-content:?space-between; ??text-align:?center; ??color:?#313131; ??font-size:?16px; ??border-bottom:?1rpx?solid?#eeeeee; ??z-index:?9999; ??background-color:?#fff; } .filterCity?{ ??flex:?1; ??position:?relative; ??height:?80rpx; ??line-height:?80rpx; } .filterJob?{ ??position:?relative; ??flex:?1; ??height:?80rpx; ??line-height:?80rpx; } .filterOrder?{ ??position:?relative; ??flex:?1; ??height:?80rpx; ??line-height:?80rpx; } .header?image?{ ??position:?absolute; ??right:?15rpx; ??top:?26rpx; ??width:?30rpx; ??height:?30rpx; } .active?{ ??color:?#ef0001; } .mask?{ ??width:?100%; ??height:?100%; ??position:?fixed; ??top:?80rpx; ??background-color:?rgba(15,?15,?26,?0.3); } .cityContainer?{ ??display:?flex; ??flex-direction:?row; ??justify-content:?space-around; ??align-items:?space-between; ??flex-wrap:?wrap; ??width:?100%; ??height:?300rpx; ??z-index:?999; ??background-color:?#fff; ??border-bottom:?1rpx?solid?#e9e9e9; ??padding-bottom:?130rpx; } .cityContainer?.city?{ ??display:?block; ??font-size:?15px; ??margin-top:?100rpx; ??width:?150rpx; ??height:?50rpx; ??line-height:?50rpx; ??text-align:?center; ??border:?1rpx?solid?#e9e9e9; ??overflow:?hidden; } .select?{ ??color:?#ffffff; ??background-color:?#ed0000; } .posContainer?{ ??height:?980rpx; ??width:?100%; ??background-color:?#fff; ??/*?overflow:auto;?*/ } ::-webkit-scrollbar?{ ??width:?0; ??height:?0; ??color:?transparent; } .title?{ ??margin-top:?55rpx; ??font-size:?15px; ??margin-left:?28rpx; } .poscontent?{ ??width:?100%; ??display:?flex; ??flex-direction:?row; ??justify-content:?flex-start; ??flex-wrap:?wrap; ??margin-top:?-15rpx; } .tag?{ ??margin-left:?28rpx; ??margin-top:?23rpx; ??font-size:?13px; ??width:?150rpx; ??height:?50rpx; ??line-height:?50rpx; ??text-align:?center; ??border:?1rpx?solid?#e9e9e9; } .confirm?{ ??width:?100%; ??height:?150rpx; ??border:?1rpx?solid?transparent; ??background-color:?#fff; } .weui-btn?{ ??position:?fixed; ??width:?95%; ??bottom:?52rpx; ??left:?50%; ??transform:?translateX(-50%); } .orderContainer?{ ??display:?flex; ??flex-direction:?row; ??justify-content:?space-around; ??align-items:?center; ??background-color:?#fff; ??width:?100%; ??height:?125rpx; } .block?{ ??font-size:?13px; ??width:?200rpx; ??height:?50rpx; ??line-height:?50rpx; ??text-align:?center; ??border:?1rpx?solid?#e9e9e9; } .search?{ ??position:?fixed; ??bottom:?80rpx; ??background-color:?#fff; ??right:?25rpx; ??width:?150rpx; ??height:?75rpx; ??line-height:?75rpx; ??text-align:?center; ??border-radius:?35rpx; ??box-shadow:?1rpx?1rpx?7rpx?7rpx?#f5f5f5; } .search?image?{ ??width:?30rpx; ??height:?30rpx; } .search?text?{ ??font-size:?15px; ??padding-left:?9rpx; ??color:?#666666; } .listContainer?{ ??width:?100%; ??height:?100%; ??margin-top:?80rpx; }
js
import?category?from?'../../api/employ' import?jobList?from?'../../api/detail' Page({ ?data:?{ ??curIndex:?'', ??isActive:?false, ??jobList:[], ??cur:?[], ??job:?[], ??isShow:?true, ??status:?0, ??isMask:?false, ??isSelect:?false, ??city:?['全國',?'杭州',?'北京',?'深圳',?'上海',?'廣州',?'武漢',?'重慶'] ?}, ?changeStatus(e)?{ ??let?status?=?e.currentTarget.dataset.status; ??let?cur?=?category; ??this.setData({ ???isActive:?!this.data.isActive, ???status:?status, ???isMask:?!this.data.isMask, ???cur:?cur, ??}) ?}, ?select(e)?{ ??let?curIndex?=?e.currentTarget.dataset.index; ??this.setData({ ???isSelect:?"?curIndex?==?this.data.curIndex???'!this.data.isActive'?:?'true'?", ???isActive:?false, ???isMask:false, ???curIndex:?curIndex, ??}) ?}, ?multiSelect(e){ ??let?multiIndex=e.currentTarget.dataset.index; ??this.setData({ ???isSelect:!this.data.isSelect, ???curIndex:multiIndex ??}) ?}, ?search(e)?{ ??wx.navigateTo({ ???url:?'../search/search', ??}) ?}, ?onLoad:?function?(e)?{ ??this.setData({ ???jobList:jobList ??}) ?}, ?click:function?(e)?{ ??let?id?=e.currentTarget.dataset.id; ??wx.navigateTo({ ???url:?`../detail/detail?id=${id}`, ??}) ?} })
I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!
Recommended reading:
Angular filter making Data case conversion
The above is the detailed content of Mini program development to create pop-up menu function (with code). For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Xianyu's official WeChat mini program has quietly been launched. In the mini program, you can post private messages to communicate with buyers/sellers, view personal information and orders, search for items, etc. If you are curious about what the Xianyu WeChat mini program is called, take a look now. What is the name of the Xianyu WeChat applet? Answer: Xianyu, idle transactions, second-hand sales, valuations and recycling. 1. In the mini program, you can post idle messages, communicate with buyers/sellers via private messages, view personal information and orders, search for specified items, etc.; 2. On the mini program page, there are homepage, nearby, post idle, messages, and mine. 5 functions; 3. If you want to use it, you must activate WeChat payment before you can purchase it;

Implementing card flipping effects in WeChat mini programs In WeChat mini programs, implementing card flipping effects is a common animation effect that can improve user experience and the attractiveness of interface interactions. The following will introduce in detail how to implement the special effect of card flipping in the WeChat applet and provide relevant code examples. First, you need to define two card elements in the page layout file of the mini program, one for displaying the front content and one for displaying the back content. The specific sample code is as follows: <!--index.wxml-->&l

Implementing picture filter effects in WeChat mini programs With the popularity of social media applications, people are increasingly fond of applying filter effects to photos to enhance the artistic effect and attractiveness of the photos. Picture filter effects can also be implemented in WeChat mini programs, providing users with more interesting and creative photo editing functions. This article will introduce how to implement image filter effects in WeChat mini programs and provide specific code examples. First, we need to use the canvas component in the WeChat applet to load and edit images. The canvas component can be used on the page

To implement the drop-down menu effect in WeChat Mini Programs, specific code examples are required. With the popularity of mobile Internet, WeChat Mini Programs have become an important part of Internet development, and more and more people have begun to pay attention to and use WeChat Mini Programs. The development of WeChat mini programs is simpler and faster than traditional APP development, but it also requires mastering certain development skills. In the development of WeChat mini programs, drop-down menus are a common UI component, achieving a better user experience. This article will introduce in detail how to implement the drop-down menu effect in the WeChat applet and provide practical

According to news from this site on October 31, on May 27 this year, Ant Group announced the launch of the "Chinese Character Picking Project", and recently ushered in new progress: Alipay launched the "Chinese Character Picking-Uncommon Characters" mini program to collect collections from the society Rare characters supplement the rare character library and provide different input experiences for rare characters to help improve the rare character input method in Alipay. Currently, users can enter the "Uncommon Characters" applet by searching for keywords such as "Chinese character pick-up" and "rare characters". In the mini program, users can submit pictures of rare characters that have not been recognized and entered by the system. After confirmation, Alipay engineers will make additional entries into the font library. This website noticed that users can also experience the latest word-splitting input method in the mini program. This input method is designed for rare words with unclear pronunciation. User dismantling

The official WeChat mini program of Xianyu has been quietly launched. It provides users with a convenient platform that allows you to easily publish and trade idle items. In the mini program, you can communicate with buyers or sellers via private messages, view personal information and orders, and search for the items you want. So what exactly is Xianyu called in the WeChat mini program? This tutorial guide will introduce it to you in detail. Users who want to know, please follow this article and continue reading! What is the name of the Xianyu WeChat applet? Answer: Xianyu, idle transactions, second-hand sales, valuations and recycling. 1. In the mini program, you can post idle messages, communicate with buyers/sellers via private messages, view personal information and orders, search for specified items, etc.; 2. On the mini program page, there are homepage, nearby, post idle, messages, and mine. 5 functions; 3.

WeChat applet implements picture upload function With the development of mobile Internet, WeChat applet has become an indispensable part of people's lives. WeChat mini programs not only provide a wealth of application scenarios, but also support developer-defined functions, including image upload functions. This article will introduce how to implement the image upload function in the WeChat applet and provide specific code examples. 1. Preparatory work Before starting to write code, we need to download and install the WeChat developer tools and register as a WeChat developer. At the same time, you also need to understand WeChat

To implement the picture rotation effect in WeChat Mini Program, specific code examples are required. WeChat Mini Program is a lightweight application that provides users with rich functions and a good user experience. In mini programs, developers can use various components and APIs to achieve various effects. Among them, the picture rotation effect is a common animation effect that can add interest and visual effects to the mini program. To achieve image rotation effects in WeChat mini programs, you need to use the animation API provided by the mini program. The following is a specific code example that shows how to
