Although the micro channel small program is a relatively simple technology, but in the interview if you can not answer some very basic concepts is not to say, so organize the article, take ten minutes to look at the interview.

1. Briefly describe the relevant file types of wechat mini programs

  • WXML (WeiXin Markup Language) is a set of tag Language designed by the framework, which can be combined with the basic components and event system to build the structure of the page. The interior is mainly a set of components defined by wechat itself
  • WXSS (WeiXin Style Sheets) is a Style language for describing the component styles of WXML
  • Js logic processing, network request
  • Json applet Settings such as page registration, page title, and tabBar

2. What are the main files and functions of wechat applets

  • Json must have this file, without this file, the project will not run, because the wechat framework uses this as the entry to the configuration file, the global configuration of the entire applet. Including page registration, network Settings, as well as the window background color of the applet, configure the navigation bar style, configure the default title
  • App.js must have this file, it will also error! But this is a file that we can just create and we don’t have to write anything and then we can listen to and process the life cycle of the applet and declare global variables, okay
  • App. WXSS optional

3. How is bidirectional binding of applets different from VUE

Two-way data binding in applets:

  • First bind the input event of the text box with bindinput
  • Declare a variable content in data and dynamically bind it to the value of the text box
  • In the bindinput event, the latest value in the text box can be obtained by using the event parameter e.daily. value
  • Two-way data binding can be realized by assigning the latest value of the text box to the dynamically bound value content through this.setData

Two-way data binding in VUE:

  • First bind @Input to the text box to listen for the input event of the text box
  • Dynamically bind the value property to the text box, whose value is the variable defined in data
  • The latest value in the input box can be obtained by using the event parameter event.target.value in the @input bound event
  • Assign the value it reobtains to the variable whose value is dynamically bound

Differences: Generally, there are little differences, such as different binding events, different ways of obtaining value, and different Settings of data in data in the small program, which need to call this. SetData method to set

4. How to transfer data between the pages of the small program

  • (1) Use global variables to realize data transfer: define global variable globalData in app.js file and store the information to be stored in it
// app.js
App({
  // Global variables
  globalData: {
    userInfo: null}})Copy the code
  • NavigateTo: wx.redirectTo: wx.redirectTo: wx.redirectTo: wx.redirectTo: wx.redirectTo: wx.redirectTo Wx. navigateTo and wx.redirectTo do not allow jumping to TAB contained pages onLoad is executed only once
// Navigate
wx.navigateTo({
  url: '.. /pageD/pageD? name=raymond&gender=male',})// Redirect
wx.redirectTo({
  url: '.. /pageD/pageD? name=raymond&gender=male',})// pageB.js
Page({
  onLoad: function(option){
    console.log(option.name + 'is' + option.gender)
    this.setData({
      option: option
    })
  }
})
Copy the code
  • (3) Use local cache Storage related

5. Talk about the life cycle functions of applets

  • OnLoad () : Triggered when the page loads. A page is called only once, and you can get the parameters in the onLoad argument to open the current page path
  • OnShow () : triggered when the page is displayed/cut to the foreground
  • OnReady () : Triggered when the first rendering of the page is complete. A page is called only once, indicating that the page is ready to interact with the view layer
  • OnHide () : triggered when the page is hidden or in the background. Such as navigateTo or bottom TAB switch to other pages, small programs into the background
  • OnUnload () : Triggered when a page is unloaded. Such as redirectTo or navigateBack to other pages

6. Advantages and disadvantages of wechat applets

advantage

  • Use to go, no installation, save flow, save installation time, do not occupy the desktop
  • Relying on wechat flow, born to promote the spread of advantages
  • The development cost is lower than App

disadvantages

  • Retention, ready-to-go, is an advantage, but there are some problems
  • The entrance is much deeper than traditional apps
  • The page size cannot exceed 2M. Pages with more than 10 levels cannot be opened

7. What is the difference between bindtap and catchtap

  • Similarities: First of all, they are used as click event functions, which are triggered when clicked. In this function they are the same, you can make no distinction
  • Difference: The main difference is that Bindtap does not prevent bubbling, catchtap does prevent bubbling

Wx.navigateto (), wx.redirectto (), wx.switchtab (), wx.Navigateback (), wx.relaunch (

  • Wx.navigateto () : Leave the current page and jump to a page in the app. But you cannot jump to the Tabbar page
  • Wx.redirectto () : Closes the current page to jump to a new page (similar to a redirection). However, jumping to the Tabbar page is not allowed
  • Wx.switchtab () : Jumps to the tabBar page and closes all non-Tabbar pages
  • Wx.navigateback (): Close the current page and return to the previous page or multi-level page. GetCurrentPages () gets the current page stack and determines how many layers you need to return
  • Wx.relaunch () : Close all pages and open to a page within the app

9. What is the login process of wechat applets

Wx. Login Obtain the code and send it to the background server to obtain the openID of the wechat user and the session key (session_key) of this login. Wx.setstoragesync (‘sessionKey’, ‘value’) after receiving the sessionKey (session_key) from the developer server

Persistent login state: The session information is stored in a cookie and returned to the server in the form of a request header, which is placed in the wx.request header in request.js

10. Unfinished… To be continued, continuously updated