Mini Program retweet function as a public method

clipboard.png

problem description

I want to write a public forwarding method in the util file. That page is called with that page, but it is not successful. How to write it, gods

the environmental background of the problems and what methods you have tried

related codes

/ / Please paste the code text below (do not replace the code with pictures)

what result do you expect? What is the error message actually seen?

Aug.19,2021

if I don't understand your train of thought, I will directly provide you with a way to write it.
follow this method directly. I directly replaced pageUrl with path

.
  • util.js

//

var log = console.log.bind(console)
var commonShareNew = function(e) {
    var that = this;
    
    try{
        var sharetype = e.target.dataset.sharetype
    }catch(e){}
    log('', sharetype)
    
// 
//
    return {
            //title: result.title,
            //path: result.let_path,
            //imageUrl: result.image,
        }
}
module.exports = {
  commonShare: commonShareNew,
}

reference
var shareT = require (".. /.. / utils/share.js") in the page; / / introduce sharing-related copywriting
page.js using
onShareAppMessage: shareT.commonShare,

Menu