The VueJS app seems to be experiencing difficulties with rendering the content

Just starting out with VueJS and I have my initial files - index.html and index.js. I want to stick with just these two files and not add any more.

Here's the content of index.html:

<html lang="en">
  <head>
    <meta charset="UTF-8">
    <title>Password strength indicator</title>
    <link rel='stylesheet' href='css/all.css'>
    <link rel="stylesheet" href="css/style.css">
  </head>
  <body>
<div id="app" class="container">
       <h1>Vue Password Strength Indicator</h1>
       <label class="frmLabel" for="password">Password</label>
       <input placeholder="Enter your password" name="password" class="frmField" 
        type="password" @input="" v-model="password" />
        <p class="frmValidation" :class="{'frmValidation--passed' : message.length > 
         7}">
        <i class="frmIcon fas" :class="message.length > 7 ? 'fa-check' : 'fa-times'"> 
        </i>
        Longer than 7 characters
        </p>
        <p class="frmValidation" :class="{'frmValidation--passed' :has_uppercase }">
        <i class="frmIcon fas" :class="has_uppercase ? 'fa-check' : 'fa-times'"></i>
        Has a capital letter
        </p>
        <p class="frmValidation" :class="{'frmValidation--passed' :has_lowercase }">
        <i class="frmIcon fas" :class="has_lowercase ? 'fa-check' : 'fa-times'"></i>
        Has a lowercase letter
        </p>
        <p class="frmValidation" :class="{'frmValidation--passed' : has_number }">
        <i class="frmIcon fas" :class="has_number ? 'fa-check' : 'fa-times'"></i>
        Has a number
        </p>
        <p class="frmValidation" :class="{'frmValidation--passed' : has_special }">
        <i class="frmIcon fas" :class="has_special ? 'fa-check' : 'fa-times'"></i>
        Has a special character
        </p>
        </div><!-- #app  -->
        <script type="module" src="index.js"></script>
    </body>
</html>

And here's what's in index.js:

import { createApp } from 'vue'

const app = createApp({
   data() {
     return {
     password: '',
    };
   },
  computed: {
    message() {
      return this.password.length > 7;
    },
    has_uppercase() {
      return /[A-Z]/.test(this.password);
    },
    has_lowercase() {
      return /[a-z]/.test(this.password);
    },
    has_number() {
      return /\d/.test(this.password);
    },
    has_special() {
      return /[!@#$%^&*(),.?":{}|<>]/.test(this.password);
    }
  },
});

app.mount('#app')

The issue I'm facing is that the content of the application is not rendering, specifically the content within

<div id="app"></div>
.

In the console, I'm seeing the following warnings:

[Vue warn]: Component provided template option but runtime compilation is not supported in this build of Vue. Configure your bundler to alias "vue" to "vue/dist/vue.esm-bundler.js". at

and

Feature flags VUE_OPTIONS_API, VUE_PROD_DEVTOOLS, VUE_PROD_HYDRATION_MISMATCH_DETAILS are not explicitly defined. You are running the esm-bundler build of Vue, which expects these compile-time feature flags to be globally injected via the bundler config in order to get better tree-shaking in the production bundle

Answer №1

To incorporate a DOM element as the template for your Vue application, runtime compilation is necessary.

Although most Vue applications do not require runtime compilation and instead utilize the esm bundler version of Vue, which excludes large runtime compilation modules in favor of single file components (.vue) compiled at build time.

You have two options:

  • Enable runtime compilation by replacing import { createApp } from 'vue' with
    import { createApp } from 'vue/dist/vue.esm-bundler.js'

    Note that this will unnecessarily increase the bundle size of Vue.
  • Use single file components (SFC's) - recommended method:

index.html:

//...
  <body>
    <div id="app"></div>
    <script type="module" src="/src/index.js"></script>
  </body>
//...

src/index.js:

import { createApp } from 'vue'
import App from './App.vue'
createApp(App).mount('#app')

src/App.vue

<template>
  <div class="container">
    ...rest of template...
  </div>
</template>
<script>
import { defineComponent } from 'vue'
export default defineComponent({
  data: () => ({
    password: ''
  }),
  computed: {
    // computed here...
  }
})
</script>

For the optimal experience and outcomes, it is highly recommended to follow the Quick start instructions.


1 - Runtime compilation is primarily designed for incremental adoption of Vue (where only parts of an existing web page are replaced and compiled at runtime), which does not apply to your scenario.

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

The useNavigate() function seems to be failing to redirect to the '/protected' route

The issue lies in the redirection process after receiving the token from the API. Although the token is successfully saved in local memory, the redirect to the intended page does not occur as expected. Instead, a manual window refresh is required to naviga ...

Avoid navigating through hidden tab indexes

Below is the HTML code that I am working with: <span tabindex="19"> </span> <span tabindex="20"> </span> <span tabindex="21"> </span> <span id="hidden" tabindex="22"> </span> <span tabindex="23"&g ...

Is there a way to determine if a file is an audio or video file using Vue.js by examining its URL?

I am currently working on a Vuetify playlist that contains a mix of audio and video media files. My goal is to create functionality that allows me to launch a video player if the file is a video, or utilize the html5 audio component for .mp3 files: ...

Inserting HTML code into the polymer

This is my HTML code: <div id="setImgWrap"> <!-- The appended image will be displayed here --> </div> Here I am appending an image from JavaScript: this.addedImages = { imageURL:self.downloadURL }; this.$.setImgWrap.append('& ...

How to make an entire video clickable on Android for seamless playback?

I have implemented an HTML5 video in my mobile web application. Currently, users need to click the small play icon at the bottom left of the video to start playing it. Is there a way to make the entire video clickable so it plays when clicked anywhere on t ...

"Combining multiple attributes to target elements while excluding specific classes

My dilemma lies in the following selector that identifies all necessary elements along with an extra element containing the "formValue" class which I aim to omit $("[data-OriginalValue][data-OriginalValue!=''][data-TaskItemID]") ...

AngularJS - ng-repeat not updating when property array changes

I have a loop in my HTML using ng-repeat: <div class="row"> <div ng-repeat="item in model.painel track by item.codigoIncidente"> <strong>{{item.restante.horaMinutoSegundo}}</strong> </div> </div> In ...

Implementing styling upon app mounting in Vue.js - a step-by-step guide

Hey, I'm working with a template code that looks like this: Here's my script code: data () { return { loadPage: true } }, mounted () { this.loadPage = true }, And here is my styling code: #app{ width: 100%; opacit ...

What is the best way to delete a particular tag using jQuery?

Illustration: htmlString = '<font><a>Test Message</a></font>'; updatedHtmlString = htmlString.find('font').remove(); Desired Result: <a>Test Message</a> This code snippet is not yielding the expe ...

The dimensions of the d3 div remain constant despite any modifications to its attributes

In my angular application, I am trying to customize the width and height of div elements in d3 when I select a legend. Strangely, I am able to adjust the width and height of the svg element without any issues. Here is the issue illustrated: Below is the c ...

After upgrading to react native version 0.73, the user interface freezes and becomes unresponsive when working with react-native-maps

After upgrading my app to the newest version of react native 0.73.x, I encountered an issue where the UI on iOS starts freezing and becoming unresponsive in production. The main screen loads react-native-maps with numerous markers, and this was not a pro ...

Internet Explorer does not support the split function in JavaScript

I've been utilizing the split function to separate dates, but I encountered an issue where the code doesn't function properly in Internet Explorer, although it works fine in other browsers. The ul and li elements are dynamically generated. <! ...

Exploring the World of Github on Windows: Understanding the 'master' and 'gh-pages' Branches

I have developed a simple jQuery plugin and uploaded it to Github. I am using both the Github website and Github for Windows to manage this project. However, when I try to include the .js or .css files from Github using the Raw links, my browser fails due ...

Display open time slots in increments of 15 minutes on Fullcalendar

Currently, I am utilizing the fullcalendar plugin with the 'agendaweek' view. My goal is to showcase the available time slots as clickable and highlight the busy ones with a red background. Handling the highlighting of busy slots is not an issue ...

The dropdown menu in Mantine is malfunctioning, even though I copied and pasted the exact code from

While following a tutorial, I encountered an issue with the Mantine Menu and Dropdown components. The tutorial creator did not wrap the React App inside the MantineProvider, which resulted in errors when trying to use the Dropdown component. Even after add ...

Best method for reverting react-native to previous version

Here's the dilemma I'm facing: I had a functional version of a react-native project that was running smoothly and committed to my git repository. Deciding to upgrade from react-native 0.26.3 to 0.28 led me into a tangled web of dependencies, so ...

Unable to find the specified element within Gmail

Recently, I've been working on a project with Nightwatch.js where it checks the dev environment and sends a test email to a Gmail account. Following that, it logs into Gmail, locates and clicks on the correct email. My main challenge now is trying to ...

Unable to automatically prompt the button inside the iframe

In this scenario, an Iframe is automatically generated by a JavaScript script. I am looking to simulate a click by triggering a button, but unfortunately, it is not working as expected. You can view the code on JSFiddle. I have attempted various approache ...

How can you ensure a code snippet in JavaScript runs only a single time?

I have a scenario where I need to dynamically save my .env content from the AWS secrets manager, but I only want to do this once when the server starts. What would be the best approach for this situation? My project is utilizing TypeScript: getSecrets(&qu ...

Mastering linear regression calculations using vue.js and chart.js

Take for instance, with the current dataset, I am looking to showcase a linear regression I managed to do this in Vista and now I need guidance on how to proceed with the calculation. I am not too familiar with using the formula Here is my HTML: <canva ...