zoukankan      html  css  js  c++  java
  • vue-class-component使用Mixins

    vue-class-component提供了mixinshelper函数,以类样式的方式使用mixins。通过使用mixins帮助程序,TypeScript可以推断mixin类型并在组件类型上继承它们。

    声明mixin的示例:

    // mixin.js
    import Vue from 'vue'
    import Component from 'vue-class-component'
    
    // You can declare a mixin as the same style as components.
    @Component
    export default class MyMixin extends Vue {
      mixinValue = 'Hello'
    }

    使用mixin的示例:

    import Component, { mixins } from 'vue-class-component'
    import MyMixin from './mixin.js'
    
    // Use `mixins` helper function instead of `Vue`.
    // `mixins` can receive any number of arguments.
    @Component
    export class MyComp extends mixins(MyMixin) {
      created () {
        console.log(this.mixinValue) // -> Hello
      }
    }
  • 相关阅读:
    接口自动化架构-获取用例
    Windows性能监控工具Perfmon使用指南
    接口自动化架构1-setting
    多进程
    线程锁、守护线程
    多线程
    xlrd模块
    封装写日志的类
    封装redis
    继承
  • 原文地址:https://www.cnblogs.com/plBlog/p/11468448.html
Copyright © 2011-2022 走看看