Comments (8)
<ui-nav>
<template v-for="(item, index) in menu" :key="index">
<router-link v-slot="{ href, isActive }" :to="{ name: item.url }">
<ui-nav-item :href="href" :active="isActive"></ui-nav-item>
</router-link>
</template>
</ui-nav>
from balm-ui.
The rendered HTML for
<router-link v-slot="{ href, isActive }" to="/">
<ui-nav-item :href="href" :active="isActive"></ui-nav-item>
</router-link>
is
<a href="/"> <!-- router-link -->
<a href="/" class="mdc-list-item" tabindex="-1"> <!-- ui-nav-item -->
<span class="mdc-list-item__ripple"></span>
Cart
</a>
</a>
I want to have one a
element per ui-nav-item
..
from balm-ui.
<router-link v-slot>
for Vue 2.0<router-link custom v-slot>
for Vue 3.0
try again!
from balm-ui.
Works like a charm, thanks
from balm-ui.
It is "working", but clicking the link makes the whole page refresh (probably cause ui-nav-item
uses a
element directly instead of using router-link
)
from balm-ui.
Indeed! <ui-nav-item>
was originally intended to define a hyperlink (like <a>
or <router-link>
)
- If you want to prevent default event, you need to use
@click.prevent
for<a>
/<ui-nav-item>
/<router-link>
- If you want to render non-hyperlink list, you can use
<ui-list>
+<ui-item @click>
from balm-ui.
Hi @elf-mouse, I'm trying to get the drawer to close when a link inside is clicked, but have no luck... :(
Can you please give me an example of a drawer with a router-link inside that closes when the link is clicked?
Thanks
from balm-ui.
<template>
<!-- Drawer -->
<ui-drawer v-model="open" type="modal">
<ui-drawer-header>
<ui-drawer-title>Test</ui-drawer-title>
</ui-drawer-header>
<ui-drawer-content>
<ui-nav>
<template v-for="(item, index) in links" :key="index">
<router-link
v-slot="{ href, isActive }"
custom
:to="{ name: item.url }"
>
<ui-nav-item
:href="href"
:active="isActive"
@click.prevent="onLink(item)"
>{{ item.name }}</ui-nav-item
>
</router-link>
</template>
</ui-nav>
</ui-drawer-content>
</ui-drawer>
<ui-drawer-backdrop></ui-drawer-backdrop>
<!-- Content -->
<div class="demo-content">
<!-- App bar -->
<ui-top-app-bar
fixed
class="demo-app-bar"
content-selector=".demo-app-content"
@nav="balmUI.onOpen('open')"
>
Test
</ui-top-app-bar>
<!-- App content -->
<div class="demo-app-content">
<p v-for="i in 24" :key="i">Main Content {{ i }}</p>
</div>
</div>
</template>
import { useEvent } from 'balm-ui';
const links = [
{
name: 'Link1',
url: 'test.main'
},
{
name: 'Link2',
url: 'test.sub'
}
];
export default {
data() {
return {
balmUI: useEvent(),
links,
open: false
};
},
methods: {
onLink(item) {
this.open = false; // close drawer
// this.$router.push({ name: item.url }); // redirect
}
}
};
from balm-ui.
Related Issues (20)
- Scroll issue when using tabs in Single Page Appplication
- UiTree组件中,选中某个子节点后,再手动修改它的vModel值,之前选中的子节点选中效果无法取消 HOT 5
- 在UiTree组件中,使用 `defaultExpandedKeys` 不能展开全部树节点 HOT 1
- Select options not showing outside of data grid row template again HOT 2
- Handle sort column HOT 1
- "FocusTrap: Element must have at least one focusable child." when the current UiDrawer item is programmaticaly set to be invisible
- Validator with the "individual usage" configuration has no validation rules HOT 2
- Console errors when having radio buttons inside of a ui-skeleton HOT 1
- Console errors when having radio buttons inside of a ui-skeleton HOT 4
- ui-tree, 赋值给v-model,是否可以自动反显出选中状态,以及打开当前选中项的树 HOT 1
- issue with using ui-editor HOT 2
- [Feature Request] Add new props support of <ui-tree> HOT 1
- Pagination change event not firing HOT 4
- Editor readonly mode not working HOT 7
- How to make balmui vue components Volar global components compatible?
- 大佬还在YB? HOT 2
- Textfield floating label doesn't follow theme colors HOT 2
- ReadMe.md Update
- Bug in focus state when clearing field HOT 2
- Remove timeout minimum for Snackbar & Toast components? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from balm-ui.