Wepy Framework API Pre-loading $preload This feature is so wide.

Source: Internet
Author: User
Tags emit

Advantage: More convenient than URL delivery, or storage, or globalData

1: If the URL can not directly pass an Object to pass the serialization and deserialization operation, Trouble (ordinary single variable is very convenient and simple)

2: If the storage also trouble, but also set to use the time to get

3: GlobalData, although more than the above two seemingly more advantages, but this interactive data is very large, all day hanging in the globalData, while hanging up to the page can be accessed to (others say can be set to NULL, even if this is not More key on GlobalData)

But a lot of preload data is only a single rendering after not, and there is no need to mount on the globalData, so I think $preload useful

$preload use

A page preload data

Note: First preload and then the page routing jump, program routing jump Ah,

Do not use the Navigator component to bind a point-and-click event preload AH

data = {      preloaddata: {        name: ' Hello ', age        : ' + '      }    ;    Methods = {      Navigatetobpage () {this        . $preload (' preload ', preloaddata)//First        Wepy.navigateto ({          URL: ') /pages/b/b?sourcepage=${this.sourcepage} '}        );      After    };    ' Preload ' name a desired variable name in good    //  preloaddata data format, defined according to your needs

  

b page Receive

  Must be in the OnLoad hook function to receive     //options for URL parameters    //Preloaddata for the previous page preload come over    //specific print out to view Preloaddata  specific What is    onLoad (options, preloaddata) {      if (preloaddata.preload && preloadData.preload.name) {        Cosole.log (' Get the data from page a preload: ', preloaddata.preload);      }    };

  

If it is the component of a page triggered, then the preload to be flexible, the method can be a variety of

1: The method that defines the methods of the component directly inside    methods = {      Navigatetobpage () {this        . $parent. $preload (' preload ', preloaddata)/ /First        wepy.navigateto ({          URL: '/pages/b/b?sourcepage=${this.sourcepage} '        );      }//After    };    //2: Communication interaction with the component    methods = {      Navigatetobpage () {this        . $emit (' Emit_parent_preload ', preloaddata);      }    };    $emit an event to go out, trigger the parent page preload    //a page in Events definition:    events = {      Emit_parent_preload (preloaddata) {        this . $preload (' preload ', preloaddata);         Wepy.navigateto ({          URL: '/pages/b/b?sourcepage=${this.sourcepage} '        );}    }

  

  

I personally use the WEPY framework to develop small programs, is very fond of using prelaod and route navigation API such a combination way to pass data!

See here, do not put you also use, try ...

    

Wepy Framework API Pre-loading $preload This feature is so wide.

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.