WeChat Mini Programs template binding functions how to write in appjs to achieve general?

tab-template.wxml
<template name="tab-template">
<button bindtap="onshow" wx:if="{{show}}"></button>
<view class="wrapper" wx:if="show">
    <view class="main">xx</view>
</view>
</template>
app.js
App({
onshow:function() {
this.setData({show:true});
},
globalData: {
  show:false
}
});

wrote a custom tab template, and now I want to add several functions to it, because there are many pages to call, one by one is very troublesome, how to make the defined functions universal?


wxs file?


currently it seems that you can only find the corresponding js file on the page that references the app.js component using the method in your app.js. Or you can take a look at Meituan's mpvue and Tencent's wepy. I hope I can help you.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1ea7534-47c0f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1ea7534-47c0f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?