admin管理员组文章数量:1237563
I'm trying to pass multiple variables in the following code:
<div v-bind:onloadstart='functionOFF = true; editOFF = true'></div>
but I get the following error:
[Vue warn]: Failed to generate render function: SyntaxError: Unexpected token ; in
I tried replacing the ;
with a ,
but the I get:
[Vue warn]: Failed to generate render function: SyntaxError: Invalid shorthand property initializer in
Any ideas on how to achieve this?
I'm trying to pass multiple variables in the following code:
<div v-bind:onloadstart='functionOFF = true; editOFF = true'></div>
but I get the following error:
[Vue warn]: Failed to generate render function: SyntaxError: Unexpected token ; in
I tried replacing the ;
with a ,
but the I get:
[Vue warn]: Failed to generate render function: SyntaxError: Invalid shorthand property initializer in
Any ideas on how to achieve this?
Share Improve this question edited Jul 12, 2018 at 9:53 squancy 5651 gold badge8 silver badges25 bronze badges asked Jul 12, 2018 at 9:51 DianaDiana 1272 gold badges2 silver badges10 bronze badges 6 | Show 1 more comment6 Answers
Reset to default 5also, you can use from below way:
<input v-bind:value="[item.id, item.name]">
spreading them in to object and using them in bind if object else add them like shown..
<MyComponent v-bind="{...$attrs, featAProps, featBProps}" />
You can use anonymous function if you don't want to declare a method:
<div v-bind:onloadstart='()=>{functionOFF = true; editOFF = true;}'></div>
According to document, v-bind should be an value or an object.
v-bind
Expects: any (with argument) | Object (without argument)
Argument: attrOrProp (optional)
You should use v-on to listen to event (in this case onloadstart). v-on can use with Inline Statement
v-on
Expects: Function | Inline Statement | Object
Argument: event
<div v-on:onloadstart='functionOFF = true; editOFF = true'></div>
In Vue 3, I wasn't having much luck with the array syntax
<MyComponent v-bind="[$attr, propA]">
but I found this comment in Vue's github repo.
This led me to try
<MyComponent v-bind="($attrs, props)" :anotherProp="anotherProp">
which ended up working for me.
FOR VUE.js ^3.3.4 and Vuetify ^3.5.0
Just tried object destruction way on the props and attributes I want to bind my button component, and it worked.
For presentation, I was trying to construct a menu button with activator props and dynamic attributes definitions for colors, custom classes etc..
<v-menu>
<template v-slot:activator=" { props, isActive }">
<v-btn
v-bind="{...props, ...filterBtnOptions}"
variant="elevated"
>
{{ `${filterActive.name} (${filterActive.number})` }}
<v-icon right :style="{ transform: isActive ? 'rotate(-180deg)' : 'rotate(0)' }">mdi-chevron-down</v-icon>
</v-btn>
</template>
//..code
</v-menu>
Here props is the activator props of the menu component and filterBtnOptions is a custom attribute object.
本文标签: javascriptMultiple variables with vbind VuejsStack Overflow
版权声明:本文标题:javascript - Multiple variables with v-bind Vue.js - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1739506121a2166270.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
&
or&&
operator maybe – Julien METRAL Commented Jul 12, 2018 at 9:55