1.1.0 • Published 2 years ago

vue-super-options v1.1.0

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

基于 Proxy,提供一个$super 处理程序,用于从子类访问父 vue 方法。 不支持 Proxy,则不可使用。 推荐使用 vue-super

vue-super is tested against vue@2 Example1:

import Vue from "vue";
import VueSuper from "Vue-super-options";
Vue.use(VueSuper);
const Parent = Vue.extend({
  methods: {
    doTheThing: function () {
      console.log("father doTheThing");
    },
  },
});

const Child = Parent.extend({
  $super: Parent,
  methods: {
    doTheThing: function () {
      this.$super.doTheThing();
      console.log("child doTheThing");
    },
  },
});

Example2:

import Parent from "@/components/parent.vue";
export default {
  methods: {
    doTheThing: function () {
      console.log("father doTheThing");
    },
  },
};

export default {
  extends: Parent,
  $super: Parent,
  methods: {
    doTheThing: function () {
      this.$super.init()
      console.log("child doTheThing");
    },
  },
};

离开页面请销毁 proxy

const Child = Parent.extend({
  $super: Parent,
  beforeDestroy() {
    // $destroy规避同名方法
    // 主动清除无用proxy的依赖
    this.$super.$destroy();
  },
  methods: {
    doTheThing: function () {
      this.$super.doTheThing();
      console.log("child doTheThing");
    },
  },
});
1.1.0

2 years ago

1.0.12

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago