Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
332 views
in Technique[技术] by (71.8m points)

能否监听并重写methods 中的所有函数调用

想在函数调用时统一添加埋点事件tranck(),但是不想每个都手动添加,希望通过监听重写的方式自动写入,请问各位大佬前辈们,这可以实现吗

  methods: {
    //页面跳转
    gotoPage(path, data = {}) {
     // this.tranck(path,data);// 方法调用前调用
      this.$router.push({
        name: path,
        query: data
      });
    },
    // 登录
    _LoginByOpenId(uuId) {
     // this.tranck(uuId);// 方法调用前调用
      LoginByToken({
        uuId:uuId,
        userId: localStorage['token']
      })
        .then(res => {
          if (res.status === 0) {
            this.LOGIN_INFO(true);
          } else {
            this.LOGIN_INFO(false);
            localStorage.removeItem('token');
          }
        })
        .catch(error => {
          console.log('--------------' + error);
        });
    },

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

我也有此问题,但是目前好像没有人这么处理,比较多的方式就是指令埋点,不过那样就需要每个地方自己手动写上


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...