f16
1
hello @nolimits4web
how can i pass options.props to route on view creation?
using navigate i do it like this:
$f7router.navigate('/page/',{ props: { date: new Date() } })
i would like to pass options.props to initial-route on view-creation.
something like this (pseudo):
$f7.views.create('.view',{
url: '/page/',
options: { props: { date: new Date() } }
})
thank you
At the moment it doesn’t, but you can just assign/specify default props values in Page component (if they are not passed)
f16
3
thank you
props values are dynamic (some of them).
same issue is with:
$f7router.navigate('/page-1/',{
openIn: 'popup',
props: { key: 'value' }
})
// '/page-1/'
<template>
<div class="page"></div>
</template>
<script>
export default (props) => {
console.log(props); // => {}
// expected => { key: 'value' }
return $render;
};
</script>
btw, i found a workaround for my issue
f16
4
here is a workaround for openIn: 'popup'
$f7router.navigate(bool ? '/popup/' : '/page/',{
props: {
pathURL: '/page/',
context: { key: 'value' }
}
})
// '/popup/'
<template>
<div class="popup">
<div class="view view-init"
data-name="${props.view}"
data-load-initial-page="false">
</div>
</div>
</template>
<script>
export default (props,{ $f7, $tick, $onMounted }) => {
Object.assign(props,{ view: $f7.utils.id('view-xxxxxxxxxx') });
$onMounted((e) =>
$tick().then(() =>
$f7.views[props.view].router.navigate(props.pathURL,{
animate: false,
props: props
})
)
);
return $render;
};
</script>
// '/page/'
<template>
<div class="page"></div>
</template>
<script>
export default (props) => {
console.log(props.context); // => { key: 'value' }
return $render;
};
</script>