Applet - by value

        // ? The first: the value of the address bar back pass, receive parameters in detail.js the onLoad lifecycle 
        toDetail (E) {
             var the above mentioned id = 10 , 
                title = "I am a detail page" ; 
            wx.navigateTo ({ 
                url: '/ Pages / Detail / Detail ID =?' + ID + '& title =' + title, 
            }) 
        } 

        // detail.js 
        the onLoad: function (Options) { 
            the console.log (Options) 
        },
        // second: in app.js, define globalData object, which is the global 
        App ({ 
            globalData: { 
                // This is written inside the parameters of any page can get the 
                name: "Qi-Long" 
            } 
        }) 

        // detail.js define constants receiving app.js 
        const = App getApp ();
         // in onLoad, onReady, onShow lifecycle can get App 
        Page ({ 
            the onLoad () { 
                the console.log (App) 
                the this .setName () 
            } , 
            the onReady () { 
                the console.log (App) 
            }, 
            onShow () { 
                the console.log (App) 
            },
            the setName () { 
                // if desired, can be re-set at a value where app.globalData.name 
                var Self = the this ; 
                self.setData ({ 
                    name: app.globalData.name 
                }) 
            } 
        })
        // The third way: the use of local cache, this approach is most commonly used. 
        // wx.setStorageSync set value ( "title", "111111111" ), in the desired page by wx.getStorageSync ( "title")
        @ Fourth way: by data-xxx pass over the value 
            <view bindtap = "goDetail" data -productId = "{{item._id}}"> </ view> 
            to pass the goods past id, to the details then from this page to the request id to the corresponding data. 
            In the event details page to get through the event object parameter passing. 
            Note: When you jump to the details page, you can also pass details of this product in the past, but if a spike of activity, after a second possible this product has not, until the time to open the details page or in the list page data, so this method is not rigorous.

Guess you like

Origin www.cnblogs.com/wuqilang/p/12076068.html