-
Notifications
You must be signed in to change notification settings - Fork 102
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
Add proxy methods #73
Comments
I don't understand what you want, or mean wqhen you say "adding methods", to be honest. An example would be helpful. |
Sorry, I'm a trainee in a company, I don't always know how to explain things well. When you convert a view project into a web component, the view-web-component-wrapper used allows you to have props, events etc in proxy. What I want is to also have the methods contained in the parent component of my project seen. function wrap modified : .... function wrap (Vue, Component) { function initialize (Component) {
let methodsList = Object.keys(options.methods || {}); hyphenatedMethodsList = methodsList.map(hyphenate); const originalMethodsAsObject = Array.isArray(options.methods) ? {} : options.methods || {}; // extract props info // proxy $emit to native DOM events injectHook(options, 'created', function () { camelizedMethodsList.forEach(key => { // proxy props as Element properties
} function syncAttribute (el, key) { class CustomElement extends HTMLElement {
} if (!isAsync) { return CustomElement |
Please format your code properly: https://help.github.com/en/github/writing-on-github/creating-and-highlighting-code-blocks Also, instead of showing me what piece of code you want to change, show me a usage example. Show me what your change allows you to do, that yoiu can't do today. Show me the problem it solves. thanks! |
An example is that I need to give logs to my component. To do this, I could change a logs property and add a watch on this property. Exemple :
Another example is that my component displays information from a database.
Thank you |
Is there a way to bind a view-model variable to the web component properties so that they can be accessed by my application I think that would also help with this issue. |
@ScottBreyer96 you probably know it already, but there is a workaround using the webComponent prop like: document.querySelector('my-element').vueComponent.refresh(); But it would be nice to create those methods on the webComponent directly. @LinusBorg I hope that the exposition of the vueComponent is good to stay... But it would be very nice to expose the methods directly outside like in this simple example eg. https://developers.google.com/web/fundamentals/web-components/customelements#extendcustomeel Thank you in advance for your hard work! |
I am sorry to add to this old issue, but I stumbled upon this as well when turning a Vue2-component into a WebComponent/CustomElement. For my WebComponent I want to be able to offer a JavaScript-API similar to what HTMLMediaElements like I already prepared a PR on my fork here https://github.com/wiffbi/vue-web-component-wrapper I would be more than happy if you consider this a worthy contribution. I built the dist-files with |
Hello, I am currently developing a web component and I would like users to be able to interact with it using methods. Can you add the methods to the wrapper? Why didn't you do it originally?
I modified the file generated by the CLI of View to test the addition of the methods, it takes little time but modifying a generated file is a bad practice and I cannot find another solution.
Can you help me by adding the methods? Is there a reason why you didn't add the methods?
Thank you
The text was updated successfully, but these errors were encountered: