The experience of the applet

For a new project, do a good job of initialization (css, html, js, configuration, request packaging, project directory, code editing habits)

  1. When using a small program to pass parameters, you can't put it in a function like vue, you can only use data-* to pass parameters
  2. For the data in data, it can be directly in vue this.xx, but in small programs, data still needs to be added. Another thing worth mentioning is that to achieve data update, you need to use this.setData(()),
  3. Components and templates are still a bit different, which can better deal with some environments, templates, and direct sets to achieve the effect of reuse

  1. Write functions in wxs to implement filtering operations in wxml ( emphasis )

  2. There is a template in the applet, to reuse, import, include

  3. The computed in vue can be divided into get, and set, the default is get

  4. For a new project, it is necessary to do the initialization work, such as prompts, some encapsulation of request

  5. Add an id or custom attribute as a logo, and when you click it, judge whether there is this logo in e.target (implementation of the masking layer)
    .-Optimize the code structure and improve the reusability

The target represents the source control that triggered the event. If the shadow part belongs to only the A control, then click the shadow part. At this time, the source control is the A control. Of course, the source control (ie A control) can be obtained from event.target.dataset. Custom attributes (because you defined them);

Clicking on other places will definitely point to the child controls of the A control (that is, other controls), then the source control is definitely not the A control, then the event.target.dataset must not get data (because you have not set custom for other controls Attributes).

For this problem, as long as you can determine whether the source control that triggered the event is the A control according to whether the custom properties of the A control can be obtained in the event.target.dataset, you can make different treatments.

Guess you like

Origin blog.csdn.net/ZHXT__/article/details/107372729