Share pictures and dynamically change the title when the micro-channel small program to achieve share button

Recently met a demand when doing small procedures, the mall is a small program, there is a share button on each item, click on the share button to share this product, are asked to share the contents of the commodity picture and caption.

The demand put me on the spot, we all know when you need to set a good trigger to share to share content in advance, because when clicking the Share button sharing function will be executed immediately, if the binding function click on the share button to share content dynamically change It is not going to work, because this time sharing function has been performed. How to change the share before the share function triggers it?

We did not find in the small community program corresponding solution, but I see someone made a suggestion on how to pass parameters when you share that bind touchstart sharing function button, awoken, for Ah, click the ordinary function does not work, use touchstart not on line yet, because the whole touchstart clicks triggered the earliest, so the problem is solved, the key is this line of code

<button open-type="share" plain="true" class="share-btn" @touchstart="setId({{item}})">
    <image src="../assets/share.png" class="icon"></image>
    <text>分享</text>
</button>

 

Published 27 original articles · won praise 6 · views 20000 +

Guess you like

Origin blog.csdn.net/github_37673306/article/details/96152632