Having trouble getting basic HTML to function with Vue.js

I am new to vue.js and decided to follow the steps in this tutorial: https://www.sitepoint.com/getting-started-with-vue-js/

After copying the code into my HTML, I encountered some issues. Could someone please assist me in identifying what might be going wrong?
Below are the snippets of code that I used:

<html>
<body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/1.0.26/vue.min.js">
</script>

<script>

var myModel = {
  name: "Ashley",
  age: 24
};

var myViewModel = new Vue({
  el: '#my_view',
  data: myModel
});

</script>
<div id="my_view">
{{ name }}
</div>
</body>
</html>

The output just displays:{{name}}

Answer №1

To successfully integrate Vue.js into your HTML file, remember to include the <head> tag and place the script at the bottom of the document as shown below:

<html>
<head>
<title></title>
</head>
<body>
<div id="my_view">
{{ name }} {{ age }}
</div>

<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/1.0.26/vue.min.js"></script>

<script>

var myModel = {
  name: "Ashley",
  age: 24
};

var myViewModel = new Vue({
  el: '#my_view',
  data: myModel
});

</script>

</body>
</html>

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

Unusual Encounters in Laravel: Navigating with React Router and the Back Button

I have nearly completed building a weather application with Laravel and have decided to integrate the front end using React/Redux/React-Router while utilizing Laravel for API calls. The only aspect that I have chosen to keep unchanged is my customized Lara ...

Show a condensed version of a lengthy string in a div using React TS

I've been tackling a React component that takes in a lengthy string and a number as props. The goal of the component is to show a truncated version of the string based on the specified number, while also featuring "show more" and "show less" buttons. ...

Troubleshooting problems with connecting Express JS and MongoDB

I've written a simple code to connect express js to mongodb, and I've installed both packages. However, I'm encountering an error. Can someone help me troubleshoot this? const express = require("express"); const app = express(); app.listen( ...

Vanilla JavaScript MVC - Send notification to controller from model upon successful AJAX completion

I am facing some challenges with my first vanilla JS MVC app. When my model sends an AJAX request to the server, the controller updates the view before waiting for the promise to resolve, resulting in an empty update on the view. How can I inform the contr ...

django, the X-CSRFToken in the request header is improperly configured

Essentially, I have managed to successfully send a CSRF token to the frontend and store it in the cookie section of the application tab within the developer console of the browser with this code: @method_decorator(ensure_csrf_cookie) def get(self, ...

Open the URL in a new tab based on certain conditions

Currently, my page redirects if a specific checkbox is selected and the "submit" button is clicked: if request.Form("myCheckbox") = "on" then response.Redirect("/newPage.asp?txt="staff"") else response.Redirect("/thisPage.asp") end if I ...

Display the cost of an item on WooCommerce once the customer has selected a button

The request was made by the customer to hide prices of products on the e-shop until a specific button is clicked. While jQuery/javascript seems like a suitable solution for this, I am curious if there are any other potential alternatives that could be mo ...

Data remaining static despite store state changes

I have a component with some data that is linked to the store's state in this way: data() { return { days: [], selectedDate: this.selectedDateComputed, dayJs: this.$store.state.dayJS, }; }, However, when the store's s ...

Interested in integrating Mockjax with QUnit for testing?

I recently came across this example in the Mockjax documentation: $.mockjax({ url: "/rest", data: function ( json ) { assert.deepEqual( JSON.parse(json), expected ); // QUnit example. return true; } }); However, I'm a bit confused abou ...

How can I extract a substring from a URL and then save it to the clipboard?

Hi there! I'm working on a project for my school and could really use your expertise. I need help extracting a substring from a URL, like this one: URL = https://www.example.com/blah/blah&code=12432 The substring is: 12432 I also want to display ...

Error Message: Unknown Custom Element <b-nav-brand> in Bootstrap-Vue.JS

I'm currently developing a Vue application and I've integrated the bootstrap-vue navbar component from the official example into my project. However, when I run my application, Vue keeps throwing a warning in the console about an unknown custom e ...

Issues with lighting on textures in Three.js

I've been working on a simple solar system project using three.js. I've completed everything, but now I'm facing an issue with adding shading when working with textures. loader.load("earth.jpg", function ( texture ) { var geometry = new ...

Unique: "Best Practices for Setting Angular.js Controller Data Directly in the Code"

In this scenario, I need to initialize the data from an inline script, even though I know how to achieve this using a promise on an http request. Currently, the controller is already defined in the header js: var testModule = angular.module('myTestM ...

Is there a way to improve the efficiency of this jQuery/JavaScript snippet by rewriting it?

I've attempted at least 25 variations of this code to make it more efficient, but each one seems to cause issues. In essence, I am assigning different classes to elements in order to trigger a css/keyframes animation when the window width is 1025px o ...

Display a q-table inside a nested row q-table component

In order to display lists within items in another list, such as a list of chapters with their titles, I am trying to achieve this using q-tables instead of q-list. Although it is usually straightforward with q-list, I am facing some challenges while worki ...

Is there a way to track dynamic changes in window dimensions within Vue?

Working on my Vue mobile web app, I encountered an issue with hiding the footer when the soft keyboard appears. I've created a function to determine the window height-to-width ratio... showFooter(){ return h / w > 1.2 || h > 560; } ...and ...

Step-by-step guide on transferring an HTML5 sqlite result set to a server using AJAX

Imagine I have a scenario where I receive a result set as shown below: db.transaction( function(transaction) { transaction.executeSql( 'SELECT col1, col2, col3 FROM table;', [],function(transaction, result){ //need to find a ...

When attempting to display an updated value in a dialog window using an ajax response for the second time, the change

Upon submission of my form, a PHP script is triggered via AJAX to perform validation. Currently, the script simply echoes the post value. For example, if a user inputs "Dog" into "formEntry," the AJAX response will display Dog. However, if the user cancels ...

Is there a way for me to update a Link To containing a parameter by using history.push with a parameter inside a table cell?

Hey there! I'm working on some code and wondering if it's doable to replace the Link To with a history.push, including the following parameter, like so: <TableCell style={{width: '10%'}}> <Link to={`/run-id/${item.run_ ...

Need a jQuery callback function in PHP that only retrieves the value without any redirection

Initially, I expected this task to be simple but it turns out my skills are a bit rusty. The snippet of javascript/jquery code that I am using is: $.get("plugin.php", {up_vote:surl}, function(data){ //alert(data); document.getElementById(&apo ...