The interview summary: https://segmentfault.com/a/11…

A brief description of the WeChat applet related file types?

There are four main file types in the WeChat applet project structure

  • WXML (Weixin Markup Language) is a set of tag Language designed by the framework. It can build the structure of the page by combining the basic components and the event system. The internals are primarily a set of components defined by WeChat itself
  • WXSS (Weixin Style Sheets) is a set of Style language used to describe the component styles of WXML
  • JS logic processing, network requests
  • JSON applet Settings, such as page registration, page title and tabBar

The main file

  • App. json must have this file. Without this file, the project will not run, because the WeChat framework uses this as the entry point for the configuration file, the global configuration of the entire applet. This includes page registration, network Settings, and the Window background color of the applet, configuring the navigation bar style, and configuring the default title
  • App. Js must have this file, not also will report an error! But we can just create this file and we don’t have to write anything and then we can listen in and handle the lifecycle functions of our applets and declare global variables in this file, right
  • App. WXSS optional

How is two-way binding for applets different from Vue?

The applet direct this.data property cannot be synchronized to the view. It must be called:

This.setData ({// Set here})

What are the methods of passing data between applet pages?

Define the global variable globalData in the app.js file to store the information you need in it

// app.js app ({// GlobalData: {userInfo: null}})

To do this, use getApp() directly to get the stored information

With wx.navigateTo and wx.redirectTo, you can put some data in the URL and initialize it on the new page onLoad

// 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 }) } })

Note: wx.navigateTo and wx.redirectTo do not allow jumping to tabs containing pages onLoad is only performed once using the local cache Storage related

The lifecycle function of a small program

  • Fired when the onLoad page loads. A page is called only once, and parameters from the path to the current page can be retrieved in the parameters of onLoad
  • Triggered when the onShow() page displays/cuts to the foreground
  • Triggers when the onReady() page is rendered for the first time. A page is called only once, indicating that the page is ready to interact with the view layer
  • OnHide () is triggered when the page is hidden/cut into the background. Such as Navigateto or the bottom TAB to switch to other pages, small programs cut into the background, etc
  • Triggered when the onUnload() page unloads. Such as redirectTo or navigateBack to other pages

The advantages and disadvantages of WeChat applet

advantage

  • Instant use and go, no installation, save traffic, save installation time, do not occupy the desktop
  • Relying on WeChat flow, natural promotion and dissemination advantages
  • Development costs are lower than apps

disadvantages

  • Retention, which is an advantage, has some problems
  • The entry is much deeper than a traditional App
  • More restrictions, page size cannot exceed 2M. Cannot open pages with more than 10 levels

How to achieve a pull-down refresh

EnablePullDownRefresh is first configured in the window of the global config. The OnPullDownRefresh hook function is defined in the Page. When the pull-down refresh condition is reached, the hook function is executed. Call wx.stopPullDownRefresh to stop the drop-down refresh

What is the difference between bindtap and catchtap

Similarities: First of all, they are all clicked event functions, which are triggered when clicked. Bindtap does not block bubbling events, whereas catchtap blocks bubbling events

WX.navigateTo (), WX.RedirecTto (), WX.SwitchTab (), WX.navigateBack (), and WX.Relaunch ()

Wx.navigateTo () : Keep the current page and jump to a page in the app. But you can’t jump to the tabbar page wx.redirectTo() : Close the current page and jump to a new page (similar to redirect). Wx.switchTab () : Jump to the tabbar page and close all other non-tabbar pages wx.navigateBack() closes the current page and returns to the previous page or multilevel page. GetCurrentPages () gets the current stack of pages and determines how many layers wx.relaunch () you need to return to: close all pages and open to a page in the app

Login process?

Login process is called WX. Login get code to the background server to get WeChat user unique identification of OpenID and the login session key (SESSION_KEY), etc.). After getting the sessionKey (session_key) from the developer server, the front end should save wx.setStorageSync(‘sessionKey’, ‘value’).

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

Commonly used instructions

Wx: for, wx: the if