How to use a conditional operation for overgive a property to a vue component or user the default - properties

I'm trying to use a conditional operation to figure out whether I have to pass a property to a vue-component or even use the default value for the component's property.
Something like that:
<my-example-component
:example-property="myValue ? {test: 1, example: 'test'} : *use default*">
</my-example-component>
You see my trouble^^
I know that this does not work in this way, but some of you may have a solution to fix my problem.
Have a nice day,
Markus ;-)

I fixed the problem by myself.
<my-example-component
:example-property="myValue ? {test: 1, example: 'test'} : NULL">
</my-example-component>
I just commit NULL if !myVlue and the child component uses the default value for its property.
Kind Regards,
Markus ;-)

Related

How do I modify the interval speed?

This question is for this component: https://ant.design/components/carousel/#header
I have attempted autoplayInterval={1000} to no success.
autoPlaySpeed is the prop that you want. You can set autoPlaySpeed={1000}, default value is 3000ms. The carousel component demo uses 'react-slick' and here is the reference for autoPlaySpeed, you can also check rest of additional API's for this plugin. Check this code snippet.

is there a way to pass muttiple values which are not in side a component(dom)?

I am very new to Vue,
i tried to simulate this in bellow link.
https://jsfiddle.net/kyncgL7w/9/
I have this simple html select tag. Where I am showing values from object(banks).
now I have used v-on:change so when ever user will select any values, i want to get values of
> ledger_object_type_sub_id and ledger_object_type_sub_name
Now, I can get the ledger_object_type_sub_id from v-bind or v-model,
but how do i pass the value of ledger_object_type_sub_name into a function.
i.e get_existing_bank_id(bank_name_id, **bank_name**) so that i can use that value can be use later on?
Thanks for your help.
Just bind object value on your option tag
<option v-bind:value="bank">..</option>
What you can do is to find in your banks array the ledger_object_type_sub_id who is equal to your bank_name_id.
get_existing_bank_id: function(bank_name_id) {
console.log(this.banks.find(bank => bank.ledger_object_type_sub_id === bank_name_id).ledger_object_type_sub_name);
}
Here is your fiddle update with the working solution : https://jsfiddle.net/sjh038w9/

Bind multiple classes to a single variable

While using Tailwind with utility-first approach to css, I often find the need to bind multiple classes to a single variable.
For instance, to style an input form, I need to add border-red, color-red, etc if there is an error.
Is there a nice and elegant way to express this in Vue instead of writing v-bind:class="{ 'border-red': error, 'text-red': error }?
You can combine both classes into the same property:
:class="{ 'border-red text-red': error }"
Another easy solution:
:class="error && 'border-red text-red'"
or for if, else
:class="error ? 'border-red text-red' : 'border-green'"
You also can concatenate strings to classnames:
:class="'border-'+borderColor"

how to solve vue short if in v-model?

I need to do a shortif in a v-model, but eslint gives the folowing problem:
[vue/valid-v-model] 'v-model' directives require the attribute value
which is valid as LHS.eslint-plugin-vue
so the code works. but its not the way it needs to work.
this is the code i have now
<v-text-field
v-show="field.type == 'String'"
v-model="_isMultiple(content_data[tabindex]) && subitem != null ? content_data[tabindex][subitem][field.name]
: content_data[tabindex][field.name]"
:label="field.name"
:counter="field.counter"
max-width="100px"
/>
So this code needs a little explanation to it.
I try to build this as an dynamic module. If I get an array back from my json response it needs to v-model the subitem. If I get an object back from the response it just needs to v-model that object.
The data (content_data[tabindex]) + field do i get from a v-for loop and other loops in my vue html
so I think its not an option to do a computed prop because
I can't get in the right data.
_isMultiple function code:
_isMultiple(content_data) {
return Array.isArray(content_data)
}
any solution for this?
Maybe you should not use v-model, but build it on your own with value binding and event listening.
v-model is only a shorthand: https://v2.vuejs.org/v2/guide/forms.html.
By implementing it on your own you can use a method to set the values and a computed property to get it.

Geb: Check if an element is not present/displayed

I want to check that a particular element is not displayed in Geb.
selectedClients { $(".selection") }
Here are several of the stuff I've tried so far: none working.
assertThat(module.selectedClients.not.displayed)
assertThat(module.selectedClients.displayed).isEqualTo(false)
Thanks in advance!
EDIT
To clear the ambiguity, what I was actually checking for here was the presence of child elements within the object. I was able to resolve this, using a size() check.
assertThat(module.selectedClients.size()).isEqualTo("0")
assertThat(!module.selectedClients.displayed)
Try iterating through each element and checking visibility
module.selectedClients.each {
assertThat(it.displayed).isEqualTo(false)
}
I'm not too familiar with junit syntax :/
Simply do this:
if(elementName.size() ==1) or not.