Skip to content

22 - custom element #986

Open
Open
@HongxuanG

Description

@HongxuanG
// your answers
<script setup lang='ts'>

import { onMounted,defineCustomElement } from "vue"

/**
 * Implement the code to create a custom element.
 * Make the output of page show "Hello Vue.js".
*/
const VueJs = defineCustomElement({
  props: {message: String},
  template: `<span>{{message}}</span>`
})
customElements.define('vue-js', VueJs)
onMounted(() => {
  document.getElementById("app")!.innerHTML = "<vue-js message=\"Hello Vue.js\"></vue-js>"
})

</script>

<template>
  <div id="app"></div>
</template>

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions