WeChat Mini Program Q&A


How to get user input


For components that can get user input, you need to use the component's attribute bindchange to synchronize the user's input content to AppService

<input id="myInput" bindchange="bindChange" /><checkbox id="myCheckbox" bindchange="bindChange" />
var inputContent = {}
Page({
    data:{
    },
    bindChange:function(e){
        inputContent[e.currentTarget.id] = e.detail.value
    }
})

Why can't you use window in a script? The script logic of the object


page is running in AppService. AppService is an environment without window objects, so window cannot be used in the script, nor can components be operated in the script

Why zepto/jquery cannot be used


zepto/jquery uses window objects and document objects, so it cannot be used.

wx.navigateTo cannot open the page


An application can only open 5 pages at the same time. After 5 pages have been opened, wx.navigateTo cannot open a new page normally. Please avoid multi-level interactions, or use wx.redirectTo

Style sheets do not support cascading selectors


MINA supports .Start class selector. For example:

  .normal_view{    color:#000000;padding:10px;
  }

You can use tag selectors to control the styles of components of the same type. For example: use the input tag selector to control the default style of <input/>.

  input{    width:100px;
  }

Local resources cannot be obtained through css


background-image: You can use network images, or base64, or use <image/>tag

How to modify the background color of the window


Use the page tag selector to modify the style of the top-level node

page{
  display:block;
  min-height:100%;
  background-color:red;
}