最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

微信小程序 彈窗輸入組件的實(shí)現(xiàn)解析

 更新時(shí)間:2019年08月12日 11:47:46   作者:kevie  
這篇文章主要介紹了微信小程序 彈窗輸入組件的實(shí)現(xiàn)解析,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下

寫項(xiàng)目的時(shí)候發(fā)現(xiàn)小程序沒有自帶的彈窗輸入的組件,只能自己寫一個(gè)。

1.半透明的遮蓋層

遮蓋層的樣式和顯隱事件

wxml代碼:

<view class="body">
 <button bindtap='eject'>彈窗</button>
</view>
<view class="model" catchtouchmove='preventTouchMove' wx:if='{{showModal}}'></view>

wxss代碼:

.model{
 position: absolute;
 width: 100%;
 height: 100%;
 background: #000;
 z-index: 999;
 opacity: 0.5;
 top: 0;
 left:0;
}

js代碼:

 /**
  * 頁面的初始數(shù)據(jù)
  */
 data: {
  showModal: false,
 },
 /**
  * 控制遮蓋層的顯示
  */
 eject:function(){
  this.setData({
   showModal:true
  })
 }

2.彈窗窗口實(shí)現(xiàn)

彈窗窗口的樣式和顯隱事件

wxml代碼:

<view class="modalDlg" catchtouchmove='preventTouchMove' wx:if='{{showModal}}'>
 <view class='windowRow'>
  <text class='userTitle'>標(biāo)題
 </text>
  <view class='back' bindtap='back'>
   返回
  </view>
 </view>
 <view class='wishName'>
  <input bindinput='wish_put' placeholder='請(qǐng)輸入內(nèi)容' class='wish_put'></input>
 </view>
 <view class='wishbnt'>
  <button class='wishbnt_bt' bindtap='ok'>確定</button>
 </view>
</view>

wxss代碼:

.modalDlg{
 width: 70%;
 position: fixed;
 top:350rpx;
 left: 0;
 right: 0;
 z-index: 9999;
 margin: 0 auto;
 background-color: #fff;
 border-radius: 10rpx;
 display: flex;
 flex-direction: column;
 align-items: center;
}
.windowRow{
 display: flex;
 flex-direction: row;
 justify-content: space-between;
 height: 110rpx;
 width: 100%;
}
.back{
 text-align: center;
 color: #f7a6a2;
 font-size: 30rpx;
 margin: 30rpx;
}
.userTitle{
 font-size: 30rpx;
 color: #666;
 margin: 30rpx;
}
.wishName{
 width: 100%;
 justify-content: center;
 flex-direction: row;
 display: flex;
 margin-bottom: 30rpx;
}
.wish_put{
 width: 80%;
 border: 1px solid;
 border-radius: 10rpx;
 padding-left: 10rpx;
}
.wishbnt{
 width: 100%;
 font-size: 30rpx;
 margin-bottom: 30rpx;
}
.wishbnt_bt{
 width: 50%;
 background-color: #f7a6a2;
 color: #fbf1e8;
 font-size: 30rpx;
 border: 0;
}

js代碼:

/**
  * 頁面的初始數(shù)據(jù)
  */
 data: {
  showModal: false,
  textV:''
 },
 /**
  * 控制顯示
  */
 eject:function(){
  this.setData({
   showModal:true
  })
 },
 /**
  * 點(diǎn)擊返回按鈕隱藏
  */
 back:function(){
  this.setData({
   showModal:false
  })
 },
 /**
  * 獲取input輸入值
  */
 wish_put:function(e){
  this.setData({
   textV:e.detail.value
  })
 },
 /**
  * 點(diǎn)擊確定按鈕獲取input值并且關(guān)閉彈窗
  */
 ok:function(){
  console.log(this.data.textV)
  this.setData({
   showModal:false
  })
 }

3.完整代碼

最后獻(xiàn)上完整代碼,有點(diǎn)啰嗦了,想盡量詳細(xì)點(diǎn)

wxml代碼:

<view class="body">
 <button bindtap='eject'>彈窗</button>
</view>
<view class="model" catchtouchmove='preventTouchMove' wx:if='{{showModal}}'></view>
<view class="modalDlg" catchtouchmove='preventTouchMove' wx:if='{{showModal}}'>
 <view class='windowRow'>
  <text class='userTitle'>標(biāo)題
 </text>
  <view class='back' bindtap='back'>
   返回
  </view>
 </view>
 <view class='wishName'>
  <input bindinput='wish_put' placeholder='請(qǐng)輸入內(nèi)容' class='wish_put'></input>
 </view>
 <view class='wishbnt'>
  <button class='wishbnt_bt' bindtap='ok'>確定</button>
 </view>
</view>

wxss代碼:

.body{
 width: 100%;
 height: 100%;
 background-color: #fff;
 position: fixed;
 display: flex;
}
.body button{
 height: 100rpx;
}
.model{
 position: absolute;
 width: 100%;
 height: 100%;
 background: #000;
 z-index: 999;
 opacity: 0.5;
 top: 0;
 left:0;
}
.modalDlg{
 width: 70%;
 position: fixed;
 top:350rpx;
 left: 0;
 right: 0;
 z-index: 9999;
 margin: 0 auto;
 background-color: #fff;
 border-radius: 10rpx;
 display: flex;
 flex-direction: column;
 align-items: center;
}
.windowRow{
 display: flex;
 flex-direction: row;
 justify-content: space-between;
 height: 110rpx;
 width: 100%;
}
.back{
 text-align: center;
 color: #f7a6a2;
 font-size: 30rpx;
 margin: 30rpx;
}
.userTitle{
 font-size: 30rpx;
 color: #666;
 margin: 30rpx;
}
.wishName{
 width: 100%;
 justify-content: center;
 flex-direction: row;
 display: flex;
 margin-bottom: 30rpx;
}
.wish_put{
 width: 80%;
 border: 1px solid;
 border-radius: 10rpx;
 padding-left: 10rpx;
}
.wishbnt{
 width: 100%;
 font-size: 30rpx;
 margin-bottom: 30rpx;
}
.wishbnt_bt{
 width: 50%;
 background-color: #f7a6a2;
 color: #fbf1e8;
 font-size: 30rpx;
 border: 0;
}

js代碼:

Page({
 /**
  * 頁面的初始數(shù)據(jù)
  */
 data: {
  showModal: false,
  textV:''
 },
 /**
  * 控制顯示
  */
 eject:function(){
  this.setData({
   showModal:true
  })
 },
 /**
  * 點(diǎn)擊返回按鈕隱藏
  */
 back:function(){
  this.setData({
   showModal:false
  })
 },
 /**
  * 獲取input輸入值
  */
 wish_put:function(e){
  this.setData({
   textV:e.detail.value
  })
 },
 /**
  * 點(diǎn)擊確定按鈕獲取input值并且關(guān)閉彈窗
  */
 ok:function(){
  console.log(this.data.textV)
  this.setData({
   showModal:false
  })
 }
})

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • Javascript數(shù)組的?splice?方法詳細(xì)介紹

    Javascript數(shù)組的?splice?方法詳細(xì)介紹

    這篇文章主要介紹了Javascript數(shù)組的splice方法詳細(xì)介紹,splice方法通過刪除或替換現(xiàn)有元素或者原地添加新的元素來修改數(shù)組,并以數(shù)組形式返回被修改的內(nèi)容。此方法會(huì)改變?cè)瓟?shù)組
    2022-09-09
  • JavaScript利用鍵盤碼控制div移動(dòng)

    JavaScript利用鍵盤碼控制div移動(dòng)

    這篇文章主要為大家詳細(xì)介紹了JavaScript利用鍵盤碼控制div移動(dòng),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2020-03-03
  • JavaScript中常見的高階函數(shù)總結(jié)

    JavaScript中常見的高階函數(shù)總結(jié)

    JavaScript的函數(shù)其實(shí)都指向某個(gè)變量,既然變量可以指向函數(shù),函數(shù)的參數(shù)能接收變量,那么一個(gè)函數(shù)就可以接收另一個(gè)函數(shù)作為參數(shù),這種函數(shù)就稱之為高階函數(shù),這篇文章主要給大家介紹了關(guān)于JavaScript中常見的高階函數(shù),需要的朋友可以參考下
    2022-02-02
  • bootstrap是什么_動(dòng)力節(jié)點(diǎn)Java學(xué)院整理

    bootstrap是什么_動(dòng)力節(jié)點(diǎn)Java學(xué)院整理

    這篇文章主要介紹了bootstrap是什么,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2017-07-07
  • JS中進(jìn)行字符串替換的方法

    JS中進(jìn)行字符串替換的方法

    replace() 方法用于在字符串中用一些字符替換另一些字符,或替換一個(gè)與正則表達(dá)式匹配的子串,這篇文章主要介紹了js中進(jìn)行字符串替換的方法,需要的朋友可以參考下
    2024-01-01
  • js實(shí)現(xiàn)本地圖片文件拖拽效果

    js實(shí)現(xiàn)本地圖片文件拖拽效果

    這篇文章主要為大家詳細(xì)介紹了js實(shí)現(xiàn)本地圖片文件拖拽效果,拖拽文件到指定位置,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-07-07
  • Bootstrap每天必學(xué)之標(biāo)簽與徽章

    Bootstrap每天必學(xué)之標(biāo)簽與徽章

    Bootstrap每天必學(xué)之標(biāo)簽與徽章,對(duì)Bootstrap標(biāo)簽與徽章小編也了解的很少,希望通過這篇文章和大家更多的去學(xué)習(xí)Bootstrap標(biāo)簽與徽章,從中得到收獲。
    2015-11-11
  • 比較新舊兩個(gè)數(shù)組值得增加和刪除的JS代碼

    比較新舊兩個(gè)數(shù)組值得增加和刪除的JS代碼

    這篇文章介紹了比較新舊兩個(gè)數(shù)組值得增加和刪除的JS代碼,有需要的朋友可以參考一下
    2013-10-10
  • 使用 UniApp 實(shí)現(xiàn)小程序的微信登錄功能

    使用 UniApp 實(shí)現(xiàn)小程序的微信登錄功能

    這篇文章主要介紹了使用 UniApp 實(shí)現(xiàn)小程序的微信登錄功能,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2020-06-06
  • 不用確認(rèn)即可打印的javascript代碼

    不用確認(rèn)即可打印的javascript代碼

    不用確認(rèn)即可打印的javascript代碼...
    2007-10-10

最新評(píng)論

灵石县| 炎陵县| 亳州市| 克什克腾旗| 祁连县| 文昌市| 西乌珠穆沁旗| 湖北省| 白城市| 芷江| 新沂市| 莲花县| 盐亭县| 白城市| 瑞安市| 金溪县| 遵义县| 柳河县| 五台县| 昌黎县| 花莲县| 南投县| 大宁县| 吉木萨尔县| 五常市| 抚远县| 广水市| 宁武县| 汤阴县| 通江县| 平凉市| 四平市| 独山县| 开化县| 兰西县| 咸阳市| 隆安县| 长治县| 关岭| 章丘市| 扎兰屯市|