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

Guide on making API calls in AngularJS using query strings

I am new to learning about AngularJS and recently came across a helpful article on connecting to an API and using its data in our app. The article specifically focuses on displaying weather information with AngularJS. The only downside is that the weather ...

"Graphs not Displaying Properly in ChartJs

Seeking assistance with rendering a chart inside a bootstrap popover. Despite various debugging attempts, the chart refuses to render. Any help or insight would be greatly appreciated. Below is my HTML code: <div id="popover-content" style=&qu ...

Getting to a nested key in a JSON object with JavaScript: a step-by-step guide

Currently, I'm working with a JSON file and need to extract the fileName tag for use. { "dataset": { "private": false, "stdyDscr": { "citation": { "titlStmt": { "titl": "Smoke test", "IDNo": ...

The issue of race condition in Node.js programming

I've been diving into the documentation, but I'm struggling to figure out what's going on here. I have two functions: one downloads a CSV file via a URL, and the next function takes that CSV file and converts it to JSON FileDownload.js co ...

Do you need to discontinue a live connection?

Currently, I am in the process of setting up a notification system using StopmJs within React. To gather the count of new messages and the message list, I have subscribed to two destinations. I am curious if there will be any memory leaks if I decide not ...

Steps for accessing the files uploaded in a React application

Looking to implement an upload button using material UI that allows users to upload multiple files, with the goal of saving their paths into an array for future use. However, I'm unsure about where these uploaded files are stored. The code snippet be ...

problem with saving session data

I am attempting to access data from another page using session storage. On my initial page, named home.html function go_to_faq(qnum){ window.open('FAQ.html', '_blank'); sessionStorage.setItem('key2', qnum); } <a s ...

Exploring CSS animations by utilizing the transform and color properties

I am currently working on a project that involves animating text (specifically "happy birthday to you") and a heart. The idea is for the heart to drop and hit each word one by one, turning them yellow upon impact. Once the last word is hit, the text shou ...

The Vue JS component fails to appear on the index.blade file within a Laravel project

I'm struggling with getting my Vue.js component to display on my project. I don't see any errors in my code, and I've looked at multiple examples to ensure I'm implementing it correctly. Can anyone offer assistance? index.blade.php fil ...

A guide on implementing multiline properties in a property file for Selenium WebDriver

At the moment, I am focusing on utilizing Selenium WebDriver with code that is developed in Java. In the snippet below, I have successfully verified if the dropdown values match the UI for one dropdown. Now, I aim to extend this capability to check multip ...

Execute the script using ajax

Is it possible to execute JavaScript within an AJAX request? I attempted to include some JavaScript code in the PHP file that was called by an AJAX command. The purpose of this script was to modify an HTML attribute on the parent page. However, it did not ...

Adding data to an array using V-Bind in VueJS

I am currently working on a project that involves retrieving data from multiple devices and displaying the data on a chart in real-time. The goal is to update the chart every second as new data comes in. Below is the code snippet I have been using: index ...

How can you conceal an HTML element when the user is using an iOS device?

I need the code to determine if a user is using an iOS device and, if not, hide the HTML input type "Play" button. So, I'm uncertain whether my iOS detection is correct, the hiding of the "Play" button in the code, or both: <!DOCTYPE html> < ...

Efficiently adding values to a variable with the forEach method

I'm encountering an issue with displaying data from a JSON file similar to the one below: Currently, "checked" is set to null. I aim to update it to true within the steps array using a forEach loop. JSON data snippet: { "id": 4, "process": { ...

Exploring the power of intercepting response.send() and response.json() in express.js

Imagine having various instances where response.send(someData) is utilized. What if you wish to implement a universal interceptor that captures all .send functions and modifies someData? Is there a method within express.js to achieve this, such as hooks, ...

HTML5 for advanced positioning and layering of multiple canvases

I have 2 canvas layers stacked atop each other, but I need to position them relative to the entire page. The dimensions of both layers are fixed at a width of 800 and a height of 300. My goal is to center the canvas layers regardless of screen size, with ...

What is the best way to utilize functions from different JavaScript files?

I'm currently handling server-side javascript and I've got confidential data that needs to remain secure, stored in a private directory. If I choose to enclose this data within a function, how can I go about invoking that function from a separate ...

Incorporating Button Value from Anchor Tag Title Upon Page Load

Currently, I am working on a real estate project and facing an issue with a contact modal box. My goal is to extract the title from tag "a" and place it as the button value in the modal box. English isn't my strong suit, so please excuse any errors i ...

The routing is not functioning properly as anticipated

Here is a route definition that I am using: routes.MapRoute( "FormPreview", "Forhandsgranska/{FormId}/{action}/{id}", new { controller = "FormPreview", action = "Introduction", id = UrlParameter.Optional } ...

React components are failing to display data as expected

I need to display certain data based on the id provided in the url. When I use console.log() with res.json, I can see the data but I'm unsure how to pass it to the 'articleComponent'. const Articles = () => { const query = (id) => ...