preface

Life indeed everywhere filled with terror, the last time to get a few offer later, went to a company salary is very good, on the first day to work, just tell me, they the project design draft was finalised last month, the UI figure above the blue lake is cut, the backend interface is already written, I think if only use the docking port will do, and the product told me, No, the front end hasn’t been written yet, the project is due next week… , took a look at the blue lake, more than 50 pages, did not write a word, next week, I, ha ha. I’m afraid I didn’t wake up. In order to come to this company, I put off all other offers. As a result, my mentality burst and I quit at night to continue looking for a job.

Goods details

After another week’s efforts, I came to a company that felt very good, but in the interview, all the questions asked were vue.js, the project explanation, and even the online demonstration, all were vue.js. As a result, after I joined the company, I was told that they wanted to develop small programs. Well, haven’t touched a mini program in a year…

Viewing product details

NavigateTo (wx. NavigateTo) navigateTo (WX. NavigateTo) navigateTo (WX. NavigateTo) navigateTo (WX. NavigateTo) navigateTo Open the page can pass this. GetOpenerEventChannel () method to obtain a EventChannel object; Wx. NavigateTo’s success callback can also contain an EventChannel object, which can listen for events using the EMIT and ON methods.

Applets development documentation

  1. On the product list display page.jsThe page jump method is defined in the file
datailFn(){
  // navigateTo the page using the wx.navigateTo method
  wx.navigateTo({
    // Location of the details page
    url: '.. /detail/detail'.// Jump to the page on success and pass the data
    success:(res) = >{
      // Pass data to the jump page (details page) via eventChannel
      res.eventChannel.emit('acceptDataFromOpenerPage',
      {goods:this.data.goods})
    }
  })
  // Pass the data to the jump page
}
Copy the code

2. Define the onLoad method in the.js file of the commodity details page to get the data

// Get the data from eventchannel.on on the redirect page
onLoad(option){
   const eventChannel = this.getOpenerEventChannel()
   // Listen to acceptDataFromOpenerPage events to get the jump page (product list page)
   // Data passed through eventChannel
   eventChannel.on('acceptDataFromOpenerPage'.data= >{
     this.setData({
       goods:data.goods
     })
   })
 // Jump to the page to get data
 }
Copy the code

End Viewing product details

The detailed content

Small program page sharing

In the development of small programs, the sharing function is often needed. Some of them use the forwarding and sharing in the upper left corner of the small program, and some of them use a separate share/forward button in the page. The implementation method is as follows:

  1. throughbuttonButton, Setopen-type='share'Attribute, which can be triggered after the user clicks the forward/analysis button on the pagePage.onShareAppMessageEvent, the implementation process is as follows:

2. Add the following code 3 to the required forwarding/sharing. Add the onShareAppMessage method to the corresponding.js file

  onShareAppMessage:function(res){
    var that = this;
    if(res.from === 'button') {//console.log(' share/forward within page ')
    }else if (res.from === 'menu') {//console.log(' share/forward at upper right corner of page ')
    }
    // Return data (add forward/shared data)
    return{
    title:that.data.info.name,
    // Add a forwarding/sharing page (entire page)
    path:'/pages/detail/detail'.// Add goods to forward/share
    // path:'/pages/food/info? id=' + that.data.info.id,
    success:function(res){
    // Forwarding succeeded
    },
    fail:function(res){
    // Forwarding failed}}}Copy the code

The last

May be into a company, the content of the interview and use completely without any relationship, but when learning, after all, more to master a foreign technology, looking for a job is always easier, in this special remind, after obtaining offers the best, ask their company do project now, how about the progress, schedule of how long, don’t go after, found that a project, The front end did not write a word, next week, mentality burst!!