Skip to content

Custom element missing methods #1369

@willtj

Description

@willtj

I've created a basic custom element based on template-custom-element but the component's methods don't seem to being added to the compiled JS.

My component

<h1>Hello {{name}}!</h1>

<button on:click="saySomething()">Click me</button>

<script>
  export default {
    tag: 'my-app',

    data() {
      return {
        'name': 'World'
      }
    },

    methods: {
      saySomething() {
        alert('Again, please don\'t do this');
      }
    }
  };
</script>

Clicking on the button throws an error:

Uncaught TypeError: component.saySomething is not a function
    at HTMLButtonElement.click_handler (App.html:3)

Full example is here: https://github.com/willtj/template-custom-element

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions