How come my Vue template files within other Vue files are not displaying properly?

I am currently working with three primary Vue files:

index.vue.js:

<template>
  <div class="tax-map-wrapper">
    <h1>this is the page where the map renders</h1>
    <Map/>
  </div>
</template>

<script>
  import Map from './components/Map.vue';
  export default {

  }
</script>

Map.vue:

<template>
  <div>
    <h1>MAP TESTER</h1>
  </div> 
</template>

<script>
  console.log("map")
  import Pagination from './Pagination.vue';
  import { debounce } from '../helpers/util.js'
  export default {

  }
</script>

<style scoped></style>

Pagination.vue:

<template>
  <div>
    <h1>MAP TESTER</h1>
  </div>
</template>

<script>
  console.log("pagination")
  export default {
  }
</script>

<style scoped></style>

Upon loading my app, I can observe the "this is the page where the map renders" text on my browser, affirming that the index.vue file is functioning correctly and its template content is visible.

However, the Map component does not render, neither does the Pagination nested within the Map.vue template file. In the console, I can see the logs for both "map" and "pagination", indicating that these files are being accessed. Nevertheless, the associated templates for these files remain unrendered. No errors are displayed in the browser; it remains blank underneath the "this is the page where the map renders".

Here is my tax_map.js:

import Vue from 'vue';
import Map from '../tax_map/index.vue';

Vue.use(Map)
document.addEventListener('DOMContentLoaded', () => {
  new Vue({
    el: '#tax-map-wrapper',
    render: h => h(Map)
  })

This is my tax_map.html.erb:

<%= javascript_pack_tag 'tax_map' %>
<div id="tax-map-wrapper"></div>

If anyone has insights into why the components within index.vue are failing to render, your assistance would be greatly appreciated. Thank you!

Answer №1

Your code in the index.vue.js file uses the Map component, but be aware that this may conflict with the Javascript Map object. It is recommended to consider changing this.

If you are using build systems like Webpack to develop Vue apps, you can refer to the documentation on local registration of components at this link.

To properly register the Map component in the module exports for index.vue, include it as shown below:

<script>
  import Map from './components/Map.vue';
  export default {
    components: {
      Map
    }
  }
</script>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the best approach to configure Nuxt.js to recognize both `/` and `/index.html` URLs?

Currently, I have set up my Nuxt.js in default mode with universal and history router configurations. After running nuxt generate, the generated website includes an index.html file in the dist folder. This means that when the website is published, it can ...

Looking for assistance in streamlining JavaScript for loops?

I am currently working on a project involving a random image generator that displays images across up to 8 rows, with a maximum of 240 images in total. My current approach involves using the same loop structure to output the images repeatedly: var inden ...

What is the best way to give stacked bar charts a rounded top and bottom edge?

Looking for recommendations on integrating c3.js chart library into an Angular 6 project. Any advice or suggestions would be greatly appreciated! https://i.sstatic.net/iiT9e.png ...

Transforming JSON data for optimal rendering in ReactJS

I'm struggling with presenting nested JSON data on my website, even though it's successfully logging the data in the console. I am utilizing ReactJS and Axios for my API call. Below is a snippet of my code: import React, {useEffect} from "r ...

jQuery struggles to locate the active class within the Bootstrap slider

Want to make some changes to the Bootstrap slider? Here is the HTML Code and jQuery: <div id="carousel-slider2" class="carousel slide bs-docs-carousel-example"> <ol class="carousel-indicators"> & ...

Attempt to transfer the $ref information to the prop data of the component

Hey, I have a Carousel component and a method like this: carousel () { return this.$refs.carousel } But when I try to pass it as a prop to another component, the data in the prop is coming back as undefined. Why is that happening? <Dots :carousel=&qu ...

Is the JavaScript code not executing properly?

There seems to be an issue with this code as it's not displaying an unordered list of HTML elements as intended. I've written the script and HTML code using Sublime Text, but even after trying to run the script in Chrome's developer console ...

Best practice for integrating Typescript into an established ASP.NET 4 Webforms project

Currently, I am working on an older asp.net 4.0 Webforms project using Visual Studio 2015. My goal is to transition from using Javascript to TypeScript for certain client side code tasks. While I have experience using TypeScript in projects outside of Vis ...

Jest testing reveals an issue with the global node-config variable being undefined

I have chosen to implement Option 2 as described in the node-config documentation. Everything runs smoothly and my global config variable is set when running outside of a testing environment. However, I encounter an issue when using vue-cli with Jest uni ...

How to Align Text at the Center of a Line in Three.js

Exploring What I Possess. https://i.sstatic.net/nAtmp.png Setting My Goals: https://i.sstatic.net/svcxa.png Addressing My Queries: In the realm of three.js, how can I transform position x and y into browser coordinates to perfectly align text in th ...

Obtain the time in a 12-hour format with "A.M." or "P.M." using Vuetify

Looking to implement a time picker in Vuetify that returns the time in a 12-hour format with "A.M." or "P.M." Encountering an error while trying to achieve this. Upon initial load, receiving a value of :undefined. https://i.sstatic.net/ba86U.png Selecti ...

I am experiencing an issue where the images are not appearing properly within the <el-carousel></el-carousel> component of Element-ui

I'm having trouble displaying images in Element-ui using the Vue Framework. The images are not showing up on the page and I am fairly new to working with Vue. Can anyone offer assistance in resolving this issue? <template> <div> <el-c ...

Export was not discovered, yet the names are still effective

There seems to be a slight issue that I can't quite figure out at the moment... In my Vue project, I have a file that exports keycodes in two different formats: one for constants (allCodes) and another for Vue (keyCodes): export default { allCodes ...

Using jQuery's click function to manipulate multiple div elements

Currently, I am attempting to use jQuery's click function in order to implement a hover effect on a selected div without having to differentiate between the divs in the JavaScript code. Here is what I have so far: $(document).ready(function(){ $ ...

Angular detects when a user scrolls on a webpage

I have developed a straightforward navigation system using Angular. The main controller is responsible for generating the menu. <nav class="{{active}}" ng-click= ""> <a href="#a" class="home" ng-click= "active='home'">Home< ...

Leveraging Bootstrap without an internet connection

In the process of developing a desktop application with Electron, I have decided to incorporate Bootstrap for its design elements. Yet, my ultimate goal is to ensure that the app remains functional offline once it is released. Is there a method available ...

What is the best way to connect v-model with a select element when dealing with nested foreach loops?

Whenever I use alert(this.property_credentials.district) in vue.js, it returns empty <select v-model="property_credentials.district" name="district" class="country selectpicker" id="selectCountry" data-size="10" data-show-subtext="true" data-live-searc ...

I keep running into errors whenever I try to run npm install in my React JS project. The only way for me to successfully install dependencies is by using npm install --force. How can I go about resolving these

I am encountering this error message while working on my project: npm ERR! code ERESOLVE npm ERR! ERESOLVE could not resolve npm ERR! npm ERR! While resolving: @mui/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="681b1c11040d1b ...

Creating a JSON data array for Highcharts visualization: rearranging values for xAxis and columns

I am facing an issue with my column chart where JSON data is being parsed in the "normal" form: Years are displayed on the xAxis and values on the yAxis (check out the fiddle here): array( array( "name" => "Bangladesh", ...

Glitch in Mean App: front-end feature malfunctioning during data storage in mongodb

I am encountering difficulties while working on a MEAN app. I attempted to establish a connection between the backend (Node.js, Express.js) and the frontend (Angular 6), but encountered some issues. The backend port is http://localhost:3000, and the fron ...