Small program Wxml data binding with JS script

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.