Skip to content
欢迎扫码关注公众号

微信小程序埋点方法

参考文章 小程序自动埋点教程 ,只需要在 app.js 中添加如下代码即可在不修改页面代码的情况下添加埋点处理。

下面的示例代码中在 onLoad 事件后增加了埋点处理。

javascript
const oldPage = Page;
Page = function (args) {
  const oldOnLoad = args.onLoad;
  args.onLoad = function (opts) {
    const _self = this;
    if (oldOnLoad) {
      oldOnLoad.call(_self, opts);
    }
    onLoadTrace.call(_self);
  }

  oldPage(args);
}

function onLoadTrace() {
  // 自定义的埋点处理
  const _self = this;
  console.log("onLoadTraceLog on " + _self.route);
}

Page Layout Max Width

Adjust the exact value of the page width of VitePress layout to adapt to different reading needs and screens.

Adjust the maximum width of the page layout
A ranged slider for user to choose and customize their desired width of the maximum width of the page layout can go.

Content Layout Max Width

Adjust the exact value of the document content width of VitePress layout to adapt to different reading needs and screens.

Adjust the maximum width of the content layout
A ranged slider for user to choose and customize their desired width of the maximum width of the content layout can go.