Small program stepping on the pit notes

After using the IDE and looking at wepyjs, I found the power of the latter. Of course, IDE is still required for preview and debugging, so the role of wepyjs is to improve development efficiency.

1. Using PostCSS

Some time ago, wepy did not officially support postcss, but related plug-ins were already under development , and the compilation was successful by viewing the source code. Note:

  • The package cssnexthas long been obsolete and is now in use postcss-cssnextwith the same usage.
  • The lang attribute of style must be specified postcssin order for the compiled script to recognize it correctly.
  • Use cssnanowill cause compilation failure, you can use plugins such as postcss-csso instead.

Other plugins of postcss can also be used as usual and can replace sass.

Second, use vue grammar check

Wepy "draws on the syntax style and functional features of Vue.js", but the standard template provided uses low-standard HTML syntax detection rules. It is recommended to use vue's recommended standard to ensure better code quality. Note:

  • Be sure to replace the value of plugins in eslintrc ['vue'].
  • Wepy is not vue after all, some rules do not apply, such as the modifier of v-on, you might as well close it directly.
  • Indent detection is not very easy to use, if your indentation habits are better, you can turn it off.

After doing this, you can automatically fix and format the code by adding it in the script section of package.json eslint --fix --ext .js,.wpy src, and the efficiency will increase instead of decreasing.

3. Custom components have major defects

The custom components of wepy 1.7 are actually only rendered once when cyclic rendering (even using multiple instances), resulting in invalid data binding and event response.

Among them, the data created by the repeat element will be bound to the data and events of the initial rendering, while the ones created by the block will be bound to the last declared event, and the data cannot be bound. With one exception, classNameboth were passed correctly!

This is a known bug, and the 2.x version is not yet available, so it involves multiple instances. It is recommended to view+class+tapimplement it separately in the page.

Guess you like

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