Based on the information provided, it seems that the issue might be related to how the internal links are being constructed and used within the application. The internalLinkName should correspond to the ID of the element on the page you want to navigate to. However, the provided code does not show how the internalLinkName is being used to construct the URL for the internal links.
Here's a possible solution to ensure that the internal links are constructed properly:
-
Make sure that the
internalLinkNamecorresponds to the actual ID of the module you want to link to. For example, if you have a module with an ID ofmodule-3560, theinternalLinkNameshould bemodule-3560. -
When constructing the URL for the internal link, you should append a hash (
#) followed by theinternalLinkNameto the base URL of the page. This will create an anchor link that, when clicked, will navigate to the element with the corresponding ID on the page.
Here's how you might adjust the createInternalLink method to include the correct URL construction:
createInternalLink: function() {
if (this.newLinkName.length < 1 || this.internalLinkName.length < 4) return;
// Construct the URL with the hash for the internal link
const internalUrl = `#${this.internalLinkName}`;
this.pages.push({
guid: this.uuidv4(),
name: this.newLinkName,
url: internalUrl, // Use the constructed URL here
level: 1,
internal: true
});
this.newLinkName = '';
this.internalLinkName = '';
this.isMakingNewInternallink = false;
},
- Ensure that when rendering the links in your template, you use the
urlproperty to set thehrefattribute of the anchor (<a>) tag:
<a v-for="page in pages" :href="page.url">{{ page.name }}</a>
This will create clickable links that navigate to the corresponding module on the page when clicked.
If the issue persists, you may need to debug further by checking the following:
- Ensure that the
internalLinkNameis being set correctly when a menu item is selected. - Verify that the IDs of the modules on the page match the
internalLinkNamevalues. - Check for any JavaScript errors in the console that might be preventing the navigation.
Remember to replace the placeholder base URL (https://default.smtv.test/) with the actual base URL of your application if needed.