Giter Club home page Giter Club logo

Comments (5)

zeeforum avatar zeeforum commented on June 6, 2024 5

In AppSidebarNav.js code is look like this:

{
	default: (props) => h(
		resolveComponent(item.component),
		{
			active: props.isActive,
			href: props.href,
			onClick: () => props.navigate(),
		},
		{
			default: () => [
			item.icon &&
				h(resolveComponent('CIcon'), {
				customClassName: 'nav-icon',
				name: item.icon,
				}),
			item.name,
			item.badge &&
				h(
				CBadge,
				{
					class: 'ms-auto',
					color: item.badge.color,
				},
				{
					default: () => item.badge.text,
				},
				),
			],
		},
	),
},

You can customize the child item using render function h. Here is my code that does the trick:

{
	default: (props) => h(
		resolveComponent(item.component),
		{
			active: props.isActive,
		},
		{
			default: () =>  h(
				RouterLink,
				{
					to: props.href,
					class: 'nav-link',
					onClick: () => props.navigate(),
				},
				{
					default: () => [
					item.icon &&
						h(resolveComponent('CIcon'), {
						customClassName: 'nav-icon',
						name: item.icon,
						}),
					item.name,
					item.badge &&
						h(
						CBadge,
						{
							class: 'ms-auto',
							color: item.badge.color,
						},
						{
							default: () => item.badge.text,
						},
						),
					],
				},
			),
		},
	),
},

I have removed href and onClick props from the original code. And shifted them into RouterLink render function and href converted to "to" attribute for RouterLink. For css added the class nav-link.

That does the trick.
Hope it helps.

from coreui-free-vue-admin-template.

sametsafak avatar sametsafak commented on June 6, 2024 1

I checked AppSidebarNav.js and set custom prop to false in h function that creates RouterLink.
It solves 2 problems and creates 2 problems.

Solved problems:
1- createWebHistory is working well. I can use template's routes without that # sign.
2- router.beforeEach was triggered twice before I set 'custom' prop to false. Now it triggers only once. Noice.

Created problems:
1- custom prop's definition in node_modules>vue router>...RouterLink says:
Whether RouterLink should not wrap its content in an a tag. Useful when using v-slot to create a custom RouterLink
Therefore now all sidebar li tags are wrapped in a tag. It is not a valid html (ul>a>li) but also it seems doesn't affect anything badly (except styles, i removed underline of li's wrapper a with css)
2- breadcrumb and other components that has router-link are working like my first comment. i guess they all have this custom property :(

from coreui-free-vue-admin-template.

sametsafak avatar sametsafak commented on June 6, 2024

@zeeforum Yes it helped, thank you!

from coreui-free-vue-admin-template.

github-actions avatar github-actions commented on June 6, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions

from coreui-free-vue-admin-template.

rofequl avatar rofequl commented on June 6, 2024

Links doesn't work properly with history: createWebHistory
The issue not resolved yet.

from coreui-free-vue-admin-template.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.