What could be causing errors in converting Vue.js code into a single HTML file?

I discovered a Vue.js sample project on this website and now I want to execute this code in a single HTML file using Vue.js.

I attempted:

<!DOCTYPE html>
<html>
<head>
  <title>My first Vue app</tite>
    <script type="text/javascript" src="https://cdn.jsdelivr.net/gh/space10-community/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="30535f5e465542435144595f5e515c1d565f425d70011e001e01">[email protected]</a>/dist/converastional-form.min.js" crossorigin></script>
  <scrpit src="https://unpkg.com/vue"></script>
</head>
<body>
  <div id="app">
    <MyForm></MyForm>
  </div>
  <script>
    Vue.component('MyForm', {
      template: '<div class="myForm"></div>',
      styles: [`
        .myForm {
          position: relative;
          height: 100%;
          width: 100%;
        }
      `],
      methods: {
        setupForm: function () {
          const formFields = [
            {
              'tag': 'input',
              'type': 'text',
              'name': 'firstname',
              'cf-questions': 'What is your firstname?'
            },
            {
              'tag': 'input',
              'type': 'text',
              'name': 'lastname',
              'cf-questions': 'What is your lastname?'
            }
          ];

          this.cf = ConversatonalForm.startTheConversation({
            options: {
              submitCallback: this.submitCallback,
              preventAutoFocus: true,
            },
            tags: formFields
          });
          this.$el.appendChild(this.cf.el);
        },
        submitCallback: function () {
          var formDataSerialized = this.cf.getFormData(true);
          console.log("Formdata, obj:", formDataSerialized);
          this.cf.addRobotChatResponse("You are done. Check the dev console for form data output.")
        }
      },
      mounted: function () {
        this.setupForm()
      },
    });
    var app = new Vue({
      el: '#app',
      data: {
        message: 'Hello Vue!'
      }
    })
  </script>
</body>
</htl>

However, it seems to not be working. Can someone help me identify any errors? Thank you!

For more information, visit the project documentation site:

Answer №1

Using PascalCase for components in an HTML file is not recommended. It is advised to change:

<MyForm></MyForm>

to:

<my-form></my-form>

The issue arises when the browser parses the HTML and converts all tag names to uppercase, causing the word boundaries to be lost.

For more information, please refer to https://v2.vuejs.org/v2/style-guide/#Component-name-casing-in-templates-strongly-recommended

I am not very familiar with the ConversationalForm library but I also had to make a similar adjustment:

this.cf = ConversationalForm.startTheConversation({

and changed it to:

this.cf = conversationalform.ConversationalForm.startTheConversation({

After making these changes, everything seemed to work successfully, although the DOM nodes are initially hidden.

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

Creating a dropdown menu in React

Imagine having an options array like the one below: options = [ { name: 'My profile' }, { name: 'Sign out' } ] public selectOptions(showOptions: boolean) { this.setState({ showOptions: !showOptions }) return options.map((opt ...

How can you handle undefined values in the query object parameter when using Mongoose's Find function?

Alright: Sound.find({ what: req.query.what, where: req.query.where, date: req.query.date, hour: req.query.hour}, function(err, varToStoreResult, count) { //perform some actions }); Let's consider a scenario where only req.query.what has a ...

The custom attribute in jQuery does not seem to be functioning properly when used with the

I am currently working with a select type that includes custom attributes in the option tags. While I am able to retrieve the value, I am experiencing difficulty accessing the value of the custom attribute. Check out this Jsfiddle for reference: JSFIDDLE ...

Is there a way to rotate the custom marker icon in vue2-google-map?

After reading the documentation, I discovered that using path is the only way to rotate the marker. In an attempt to customize my marker, I created my own PNG image. However, I have been unsuccessful in overriding the CSS of the marker. I even tried to ov ...

Click on the image to prompt the file upload dialog box to open

Is it possible to open the image upload file dialogue box when clicking the button tag? If so, how can I achieve this using PHP? while{ echo "<td><button><img src='".$cfet['productimage']."' width=&apos ...

A guide on extracting/filtering information from JSON files using JavaScript

Is it possible to extract specific data from a JSON file using JavaScript? I have imported a JSON file into my local JavaScript and I am having difficulty in retrieving and displaying certain information. Could someone offer assistance with this? The JS ...

Streaming data from the server to a Three.JS 3D cube model via Server Sent Events (SSE) is experiencing sluggish performance

In my current project, I am working on developing a client-server application that involves taking accelerometer data via SSE and passing it to a three.js model for rendering in the browser. Specifically, the application's goal is to visualize real-ti ...

In order to make Angular function properly, it is crucial that I include app.get("*", [...]); in my server.js file

Recently, I delved into server side JavaScript and embarked on my inaugural project using it. The project entails a command and control server for my own cloud server, operating with angular, Expressjs, and bootstrap. Presently, I am encountering challeng ...

The Marionette collection event vanished upon switching regions

My current situation involves using Marionette in the following way: I have three distinct regions set up A CompositeView is being displayed in one of the regions The collection within the Composite View has automatically added three different events: ad ...

Transforming a value within a controller into a directive

I am uncertain if I am approaching this correctly, but my goal is to convert a piece of code from a controller to a directive. The reason for this change is that I want to reuse the code with different values without creating multiple large object literals ...

Arrange the JSON data retrieved from an HTTP request using a function before storing it in Firestore

I am in need of a function that can efficiently handle information received from an HTTPS request and categorize the data into specific collections or documents depending on its content. For instance, if I receive a JSON object with the data "Color: blue, ...

Discover the depth of a deeply nested array

I have a complex array structure that looks something like this: I am trying to determine the depth of this nested array, focusing on the element with the most deeply embedded children. let arr = [ { name: 'tiger', children: [{ ...

What is the requirement of using Visual Studio and C++ to install node modules?

After updating my node version to 14+ from 10+ in a Vue.Js application, I encountered an error that directed me to install Visual Studio with C++. Once I installed VS with C++, the issue was resolved and everything worked smoothly. However, I noticed that ...

How to implement div scrolling on button click using Angular 4

Is there a way to make the contents of a div scroll to the left when one button is clicked and to the right when another button is clicked? I've tried using ScrollLeft, but it doesn't seem to be working... Here's the HTML code: <button ...

Issue encountered when trying to view images stored locally

As a beginner in the world of Angular framework and web development, I am struggling to display images stored in local storage. <tr *ngFor = "let item of unused; let i = index ; "> <div style="padding-left:25%;padding-top:0%;" class="row" ...

Django: What is the best way to utilize AJAX for updating my database?

One feature of my web application is that users have a coin balance along with a timer. When the countdown timer reaches zero, I want the user's coin balance to go up. Within the Django framework, I access the user's coin balance using: {{ reque ...

Body section CSS selector

Can a CSS selector be included within the body section of an HTML document? Here's an example of my code (although it is not functioning as expected): <html> <head> </head> <body> <div style= "a[target=_blank] {backgroun ...

Incorporate dots into every slide using the React Slick slider

When implementing a slider in React.js, I use React Slick. The API provided by React Slick allows us to easily incorporate previous and next buttons on each slide using the Previous and Next methods. However, I am curious about how to achieve the same fun ...

Express JS res.send() with an array response data is posing a concern during the Checkmarx scan

When using the axios library in my express middleware to retrieve responses from APIs, I encountered a security concern raised by Checkmarx scan report. router.post(someurl,req,res) { axios .get(someurl) .then((response=>{ **res.send(response.data);**/ ...

Is it possible to utilize the "let" keyword in JavaScript as a way to prevent global-scope variables?

While working on a JavaScript test, I came across an interesting observation related to the let keyword. Take a look at this code snippet: let variable = "I am a variable"; console.log(window.variable); Surprisingly, when I tried to access the variable p ...