Wechat Mini Program Knowledge Collection

1. Custom attribute/get attribute value

Custom properties:

<view bindtap='shopPost' data-myid='item.goods_id' ></view>

Get properties:

shopPost:function(e){ 
  //var postId = e.Target.dataset.myid;
  var postId = e.currentTarget.dataset.myid
}

 

2. Passing/Getting Parameters


Get parameters and pass parameters

onPostTap:function(e)
{
  // Get custom myid 
  let postId= e.currentTarget.dataset.myid;
  wx.navigateto({
  url:'detail?id='+postId
})
}

The detail page receives parameter values:

onLoad:function(options)
{
    let postId=options.id;
}

 

3, Image image achieves 100% width and height adaptive

Set the bandwidth to 100% and add the attribute mode="widthFix", such as:

<image style="width: 100%;" src="../../images/hello.png" mode="widthFix">

 

Reference document:
https://www.w3cschool.cn/weixinapp/1k7h1ug9.html

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325900115&siteId=291194637