网友真实露脸自拍10p,成人国产精品秘?久久久按摩,国产精品久久久久久无码不卡,成人免费区一区二区三区

小程序模板網

微信小程序開發問答《六十四》賦值undefined & wx for中對滿足條件的項添加class

發布時間:2018-04-23 11:47 所屬欄目:小程序開發教程
1、微信小程序,每次修改自動編譯后都會跳首頁問題
 
在app.json中,page數組里,把你正在調試的page放在最上面

 

 

2、微信小程序賦值undefined 新手求解

在事件函數中傳值給data 中的inputValue變量 但是實際上inputValue的值確實undefined 具體原因是在查不清楚 求各位幫幫忙 感謝 網上給出的一些方法都嘗試過還是不行

  data: {
    inputValue:" ",
    resultset: [{text:"aaa"},{text:"bbb"}, {text: 'ccc'}, {text: 'f' }],
    
    showClearBtn: false

  
  },
searchActiveChangeinput: function (e) {
     const val =e.detail.value
     console.log("輸入"+val)
     this.setData({
       'data.showClearBtn': val != '' ? true : false,
       'data.inputValue':e.detail.value
     })
     console.log("搜索"+this.data.inpuVaue)
  },

答:

不應該這樣寫'data.inputValue',
如果一個對象是,userinfo:{ins:1},可以寫成'userinfo.ins'這樣
ps:
this.setData({
   inputValue:"258963",
    'userinfo.ins':"2589"
})
0

上面定義:inputValue:" ",
下面使用:console.log("搜索"+this.data.inpuVaue)

0

this.setData你可以理解為異步的,所以底下直接用是不行的.

0

我記得好像setDate的時候,不需要data吧,你試試

`this.setData({
   'showClearBtn': val != '' ? true : false,
   'inputValue':e.detail.value
 })`
 
0

樓上一看就是寫react的,你這寫法不對,this.data['data.inpuVaue'],這樣就有值了。

this.setData({
  a: 1,
})
console.log(this.data.a);
//1

 

3、wx for中對滿足條件的項添加class

 

我想在這個遍歷中通過daysList數組下標和 另外一個數組中的值進行比較,如果相等則添加類名checked,就是一個背景圖標。底下代碼中添加的類名thisDay只是一個標簽的類。

請輸入代碼

<text wx:for="{{daysList}}" wx:key="*this" wx:for-index="idx" word-wrap:="" break-word;="" margin:="" 0px;="" padding:="" 0px;"="" 1.5em="" color:="" font-family:="" helvetica="" pingfang="" hiragino="" sans="" wenquanyi="" micro="" microsoft="" line-height:="" background-color:="">這個是另一個數組:

<view wx:for="{{signDays}}" wx:for-item="jitem">{{jitem}}view>

想把兩個數組的內容關聯起來,不知道怎么辦,請大神指導下該怎么弄。絕望中...

 

答:那你在視圖層肯定是不行的,感覺要在js里去遍歷然后再在視圖層去wx:if

 

4、微信小程序:隱藏和顯示功能

app.js

 

			
  1. Page({
  2. data:{
  3. showView:true
  4. },
  5. onLoad:function(options){
  6. // 生命周期函數--監聽頁面加載
  7. showView:(options.showView=="true"?true:false)
  8. }
  9. ,onChangeShowState:function(){
  10. var that=this;
  11. that.setData({
  12. showView:(!that.data.showView)
  13. })
  14. }
  15. })

app.wxml

 

			
  1. [html] view plain copy
  2. <viewclassviewclass="page">
  3. <view >
  4. <buttonbindtapbuttonbindtap="onChangeShowState">{{showView?'隱藏':'顯示'}}button>
  5. view>
  6. <view class="bright789_view_hide{{showView?'bright789_view_show':''}}">
  7. <textclasstextclass="bright789-text">我是被顯示被隱藏控件text>
  8. view>
  9. view>

app.wxss

 

			
  1. [html] view plain copy
  2. .bright789-text{
  3. font-size: 40rpx;
  4. line-height: 40px;
  5. color: #ff0000;
  6. }
  7. .bright789_view_hide{
  8. display: none;
  9. }
  10. .bright789_view_show{
  11. display: block;
  12. }
 
 
 


易優小程序(企業版)+靈活api+前后代碼開源 碼云倉庫:starfork
本文地址:http://www.xiuhaier.com/wxmini/doc/course/23925.html 復制鏈接 如需定制請聯系易優客服咨詢:800182392 點擊咨詢
QQ在線咨詢
AI智能客服 ×