In my nativescript-vue application I have a singleFile component called profileForm. I want to use that component in two ways, if the user is logged in I want to have that component as the slot of my layout component to edit profile. Otherwise I want is as a registration form.
I don't want to create an extra component for handling this. So in one case I would like to have my component wrapped in a tag so I can navigate to it, with Vue.$navigateTo, in another case I'd like to wrap it in a component. But the component has a tag in itself so in that case I don't want the anymore.
In django templates I would do something like this:
<template>
<Page v-if="is_signup" actionBarHidden="true">
<AppLayout v-else title="Profile">
...
</AppLayout v-else>
</Page v-if="is_signup">
</template>
But of course this would not work in vuejs. Is there any way to achieve this in vuejs?
I could create a new component and wrap this there like so:
<template>
<Page v-if="is_signup" actionBarHidden="true">
<ProfileForm/>
</Page>
<AppLayout v-else title="Profile">
<ProfileForm/>
</AppLayout>
</template>
But I'd rather not create a new component for this task.
I was hoping to get something like this:
<template>
<template :is="is_signup?'Page':'AppLayout'" :v-bind="is_signup?{actionBarHidden:true}:{title:'Profile'}">
...
</template>
</template>
Does nativescript-vue have such syntax?
v-if
the renderer never enters the block: which would include the applayout. – Alar:is
binding somewhere. I think it is discussed here... not much mention of it anywhere in the docs nativescript.org/blog/… – AlarisLogin
and depending on route make it true or false. – Moro<component :is />
dynamic component and thev-if="" - v-else
directive is probably the right direction. – Trafalgar<Page actionBarHidden="true"><Label text="hello"/></Page>
if is_signup is true and<Label text="hello"/>
otherwise? – Brag