We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Functions in methods cannot be called directly from a custom element(在自定义元素中无法直接调用methods中的方法)
methods functions can be used in custom elements(methods的函数可以在自定义元素上使用)
example(示例)
// setup // Button.ce.vue <script setup> import { defineExpose } from 'vue' const test = ()=>{ console.log('123') } defineExpose({ test }) </script> <template> <div class="btn"> <slot></slot> </div> </template>
// option // Button.ce.vue <script> import { defineComponent } from 'vue' defineComponent({ methods: { test(){ console.log('123') } } }) </script> <template> <div class="btn"> <slot></slot> </div> </template>
// app.vue <script setup> import { defineCustomElement, onMounted } from 'vue' import Button from './Button.ce.vue' const IButton = defineCustomElement(Button) customElements.define('i-button', IButton) onMounted(()=>{ document.querySelector('#test').test() // like this(这种方式调用) }) </script> <template> <div> <i-button id="test">test</i-button> </div> </template>
The text was updated successfully, but these errors were encountered:
duplicate: #5540
Sorry, something went wrong.
No branches or pull requests
What problem does this feature solve?
Functions in methods cannot be called directly from a custom element(在自定义元素中无法直接调用methods中的方法)
What does the proposed API look like?
methods functions can be used in custom elements(methods的函数可以在自定义元素上使用)
example(示例)
The text was updated successfully, but these errors were encountered: