Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Analyzing Vue.extend when class component extends Vue.extend #2261

Open
1 task done
yoyo930021 opened this issue Sep 8, 2020 · 0 comments
Open
1 task done

Analyzing Vue.extend when class component extends Vue.extend #2261

yoyo930021 opened this issue Sep 8, 2020 · 0 comments

Comments

@yoyo930021
Copy link
Member

yoyo930021 commented Sep 8, 2020

  • I have searched through existing issues

Feature Request

<template>
  <button :class="className" v-on:click="onClick">
    <slot></slot>
  </button>
</template>

<script lang="ts">
import Vue from "vue";
import Component from "vue-class-component";

const ButtonBase = Vue.extend({
  props: {
    block: {
      type: Boolean,
      default() {
        return false;
      },
    },
    variant: {
      type: String,
      default() {
        return "primary";
      },
    },
  },
})

@Component
class Button extends ButtonBase {
  get className(): string {
    let classes: string[] = ["btn"];

    if (this.$props.block) {
      classes.push("btn-block");
    }

    classes.push(`btn-${this.$props.variant}`);

    return classes.join(" ");
  }

  onClick(event: MouseEvent) {
    this.$emit("click", event);
  }
}

export default Button;
</script>

We can't get these props like block and variant.

From: #2254 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant