微信ウィジェット開発ノート


1.[wxss]透明度のあるrgb色を設定します:rgb(0,0,0,0.5);2.ウィジェットはiOSのようなNSNotificationを使用します:(サードパーティ:https://github.com/icindy/WxNotificationCenter)(1)通知の送受信が必要なページにWxNotificationCenter:var WxNotificationCenter=require("../....../......../component/WxNotificationCenter/WxNotificationCenter.js");(2)onLoad時にリスニングを登録し、onUnload時にリスニングWxNotificationCenter.addNotification("didSelectOrderClient",this.didSelect,this)WxNotificationCenter.removeNotification("didSelectOrderClient",this)(3)WxNotificationCenter.postNotificationName("didSelectOrderClient");3.[wxss]文字は改行せず、超えた部分に省略記号を表示する:white-space:nowrap;overflow: hidden; text-overflow:ellipsis; 4.[js]ナビゲーションは複数ページのwx.navigateBack({     delta:2})5.遅延動作settimeout(function(){   //実行を遅らせるコード 
},1000)//遅延時間ここで1秒 
6.オブジェクトを作成するときに、属性名が変数の場合は[]を付ける必要があります.
params: {      [key]:value,
},
7.オブジェクトの属性値を取得する場合、属性名が変数の場合、"."で取得できない場合は、[]を使用します.
permission[mykey]
 
8.json文字列->オブジェクト(サーバインタフェースから文字列配列オブジェクトを取得するなど):
 
var jsonObj = JSON.parse(jsonStr);
 
9.オブジェクト->json文字列(たとえば、ページの値転送時のオブジェクトタイプは、文字列を先に回転し、新しいページに戻ってからオブジェクトに戻ることができます):
var jsonStr = JSON.stringify(jsonObj)
 
 
10.jsコントロールの高さを取得
まずxmlオブジェクトにidをあげます.
次にjsで、1つのSelectorQueryで対応するidのノードを選択し(idの前に番号を付けることに注意)、対応するノードの属性を取得することができます.高さ:
//ノードセレクタvar queryの作成=wx.createSelectorQuery();//id query.select('#mjltest').boundingClientRect()query.exec(function(res){ //resはmjltestとラベルされたすべての要素の情報の配列である  console.log(res);  //高さをとる  console.log(res[0].height);
})
 
11.データを前のページに返信
let pages = getCurrentPages()
let prePgae = pages[pages.length - 2]
prePgae.setData({
     needUpdate: true
})

12.cssにおけるposition属性およびz-index属性を深く理解する:https://www.cnblogs.com/zhuzhenwei918/p/6112034.html
13.jsでview幅、高さを取得
//       
    var query = wx.createSelectorQuery();
    //  id
    query.select('.card_top_content').boundingClientRect(function (rect) {
      console.log(rect.height)
      console.log(rect.width)
    }).exec();

14.【wxss】buttonを透明に設定:
.a_button{
  background-color: rgba(255, 255, 255, 0);
}

.a_button::after {
  border: 0;
} 

15.showModalはキャンセルボタンを表示しない:
wx.showModal({
              title: '  ',
              content: res.data.message,
              showCancel: false
            })