Issue with Vue js variable not functioning properly when the page is in operation

Trying to integrate vue.json into my asp.net mvc project by downloading vue.js from the nuget package and dragging it into the layout. After running the project, I encountered the following output:

Code output https://i.sstatic.net/ZGRpN.png

or this https://ibb.co/fMa2eU

Here is the source code for layout.cshtml:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>@ViewBag.Title - My ASP.NET Application</title>
    @Styles.Render("~/Content/css")
    @Scripts.Render("~/bundles/modernizr")
    <script src="~/Scripts/vue.min.js"></script>
</head>
<body>

        @RenderBody()

</body>
</html>

And this is the code for index.cshtml:

<div id="#vueapp">
<input type="text" v-model="firstName"/>
    <p>{{ firstName }}</p>
</div>
<script>

    var mainvue = new Vue({
        el: "#vueapp",
        data: {
            firstName:"fasdfa",
        },

    })
</script>

Encountering issues with the implementation and seeking assistance to resolve the problem. Any help would be appreciated.

Answer №1

You have a syntax error in your HTML code. Avoid using id="#vueapp"; remove the # and use id="vueapp" instead. Make sure to keep el: "#vueapp" as that's how you reference an id.

Answer №2

One possible reason for this issue could be due to using a 'incorrectly dated script'. It is important to be aware of the most up-to-date version of Vue.js and to use the appropriate script for your specific project.

At the time of writing this response:

<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>

is the recommended script for Vue 3.

Alternatively, you can visit the website to find the latest available script, or to find the best match for the node version installed on your system.

Peace!

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 way to access and verify data from an array that has been passed through props

I am working with a component that takes an array as a prop <Component runners={['1','2']}/> Inside this functional component, my goal is to generate an element for each value in the array. Here's my logic: const { runners ...

Tips for properly applying the CSS display property to images

I have a piece of HTML code that includes an image of Rapunzel. The image has the style attribute set to display inline, but when I try to retrieve the display property using JavaScript, it always returns 'block' instead. I have tried using both ...

SQL for Year and Quarter Data Analysis

Is there a way to retrieve data from a SQL Table based on quarters and Years? Here is the format of my data: [![enter image description here][1]][1] Desired data [![enter image description here][2]][2] [1]: https://i.sstatic.net/gU2aO.png [2]: htt ...

What is the best approach for creating a dynamic table in this situation?

I am struggling with creating a table from a variable that contains an array of arrays, which is parsed code from an excel file. I attempted to upload the file and build the table using the following approaches: tabela.forEach((elem, index) => { cons ...

KnexJS Update Error: Failed to perform database update operation

I'm attempting to update a specific line in my database by utilizing Knex's update method. Although the command returns success, I notice no changes reflected in my database upon inspection. Below is the code snippet: async multipleConciliation( ...

Failure [ERR_STREAM_WRITE_AFTER_END]: writing past the endpoint [npm-request using socket.io]

My server has a socket server running, and on my laptop, I have a socket.io-client service. When both are turned on, they establish a connection. When other users request information from my server, the server sends that request to my laptop via a socket. ...

What is the process for integrating Vue plugins into Vue TypeScript's template?

Seeking guidance on integrating Vue plugins into Vue TypeScript's template, for example with vue-webpack-typescript. Specifically interested in incorporating vue-meta. Included the following code in ./src/main.ts: import * as Meta from 'vue-me ...

Email is functional on a local level, however, it is experiencing technical

I am facing an issue with sending out emails after a button click event. Everything works perfectly fine when testing from my local machine as the email is sent successfully and I receive a popup message confirming that the "call has been resolved". Howeve ...

It appears that Vivus JS is having difficulty animating specific <path> elements

I've been experimenting with the Vivus JS library, which is fantastic for animating paths such as drawing an image. However, I'm facing an issue where my SVG icon should animate to a 100% line-width, but it's not working as expected. Interes ...

Has anyone encountered a compile error where they are required to use a comma instead of a semicolon in an axios call?

Encounter a compilation error unless I include a comma in an axios request. The error message is: 'Unexpected token, expected ","' Within a Vue component, I am making an axios call. axios .get('/api/messages/'+this.issue) ...

Challenges arise when attempting to pass array data from Ajax to Google Maps

I'm facing an issue with my Google map. I have a data array that is dynamically returned, and I want to use it to add markers to the map. However, the markers don't work when I pass the data variable to the add_markers() function. It only works i ...

Determine if a specific identifier is already present using Javascript or Jquery

Is there a way to determine if an html tag with its specific id is present more than once in the code? This is my pseudocode for checking: if($('#myId').length > 1) { // It exists twice } ...

Vuejs does not wait for the server response when sending an asynchronous Axios ajax request

After applying various filters, I am trying to retrieve a list from the server. However, Vue.js does not wait for the server response. <input type="text" name="oooo" @input="getUsers"> ... methods: { g ...

Is it possible to personalize Carousel-indicators within react-bootstrap?

I'm currently utilizing the Carousel component from . My goal is to customize the carousel-indicators, adding text and making them appear as buttons with text. However, when I attempt to do so, React renders 'ol' tag into a new CarouselItem ...

Discord.js: Merging strings while pushing to an array

I am currently updating an embed message to notify users who have "enlisted" in a list by reacting. However, I am encountering an issue where the strings from the entire array are getting combined when the length of the array reaches 2 before adding a new ...

Guide on enabling a plugin for Stylus in a Vue 2 project using the webpack template

I am working on a Vue2 project with the Webpack template and utilizing Stylus as a CSS preprocessor. I'm facing difficulties in applying plugins for Stylus like rupture. I attempted to adjust the options in build/utils.js for the stylus loader by add ...

What is the reason for node-sass being rebuilt after upgrading from npm6 to npm7?

My application utilizes sass opposed to node-sass. Within my package-lock.json file, there is no mention of node-sass. I have been successfully using npm 6 for years without any issues. However, upon attempting to run npm install with npm 7, I encounter ...

Finding the current week using date information from an array of objects in JavaScript

I have an array of objects with a date key, and I am trying to filter out the objects that fall within the current week. How can I achieve this and get the objects from the current week? I attempted to use the filter method, but I believe I need to forma ...

Misunderstandings between HTML and CSS

Can someone please clarify how the functionality of the active-slide class? Code: <div class="slider"> <div class="slide active-slide">..</div> <div class = "slide slide-feature">..</div> <div class = "slide">..</di ...

The components declared in the index file are rendered on every route throughout the React application

I'm a beginner with React and I'm using react-router version 6.0.2. My issue is that I created a component for the router and then called this component in the index file. However, when I add another component to the index file, it gets rendered ...