We know that jquery is Dom first and that data is preferred in angular. The small program draws on the angular, also takes the data first. Today, let's look at how data binding is implemented in small programs.
1. Use "false data" in Xxx.js:
Data: {
}, Onload:function (options) {var post_content1={date: ' OCT ', title: ' Autumn Moon ', post_img: '/image/post/crab.png ', CO Ntent: ' Your name. "is directed by the new Hai Cheng, from Shinki, animation sound as the main voice of an original Japanese animation film ', View_num: ' 999 ', Collect_num: ' 999 ', author_img: '/image/avatar/1.png ',}// The following statement sets the data, the parameter must be a JSON type, which is equivalent to the data obtained this.setdata (POST_CONTENT1); } 2. The call data syntax in Xxx.wxml is: {{variable name}}; For example: Gets the date data, the syntax is: {{date}}, the effect is also out, the perfect implementation of data binding. Note that the applet will oh in that binding is one-way bound, meaning that the data is changed in the Wxml, the data in JS is unchanged.
Small program Wxml data binding with JS script