-
Notifications
You must be signed in to change notification settings - Fork 88
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
Usage in Vue framework template: passing dynamic data to the property #111
Comments
One of the design patterns in the hybrids library is using properties over attributes for dynamic values. It really makes sense, as attributes were designed for static HTML files (which basically don't change dynamically). Also, all of the built-in attributes are sync with the corresponding property on the DOM element. The As a result, you should notify the Vue template engine, that your intention is to set property, not an attribute. To do that, you can simply add <template>
<div id="app">
<dynamic-prop-test :num.prop="num"></dynamic-prop-test>
<br>
Vue Num: {{num}}
</div>
</template> EDIT: Quote from the Vue docs:
|
Thanks for the pointer! Now I'm wondering, why Vue doesn't make passing by property instead of attribute the default? Closing since appending |
I'm surprised as well. For example |
You may be interested to know that the Here's the issue where the proposal was introduced: This makes passing props by property much simpler syntactically: <my-component .my-prop="myValue" ...></my-component> Edit: I've tried the shorthand syntax but ran into some trouble. I created a Vue issue to track: |
@smalluban - please feel free to close if you feel this is not the right venue for this question - It has more to do with the interaction between Vue and Hybrids than it does the Hybrids API.
I am having some trouble passing props from vue components to hybrids web components inside a .vue file template.
A brief, very simple example:
https://codesandbox.io/s/vue-hybrids-dynamic-prop-issue-dzis6?file=/src/App.vue
Though I've come to understand that Vue, by default passes props as properties (as opposed to attributes), it appears that this is not the behavior with a hybrids component in a Vue component template (you can see that the fallback attribute value appears to be updating), but the
num
property inside the component remains 0.I was wondering if you had any feedback or suggestions on how to work around this problem? Thanks very much!
The text was updated successfully, but these errors were encountered: