Proper method for implementing an external component on a webpage using the Vue.js 3 CDN

As a developer working with ASL.NET Core, I have been exploring the integration of vuejs to build intricate forms. To familiarize myself with Vue.js components, I have been creating static HTML files as examples. One such example can be seen below:

<!DOCTYPE html>
<html lang="en">
<head>
    <title>Vue 4 Tutorial</title>
</head>
<body>
    <div id="app"></div>
    <script src="https://unpkg.com/vue@next"></script>

    <script src="https://unpkg.com/vuejs-datepicker"></script>

    <script type="text/javascript" src="https://unpkg.com/@vueform/multiselect"></script>
    <link rel="stylesheet" type="text/css" href="https://unpkg.com/@vueform/multiselect/themes/default.css">
    
    <script>
        const app = Vue.createApp({
            data: () => ({
                example1: {
                  value: 0,
                  options: ['Batman', 'Robin', 'Joker']
                }        
            }),
            template: `<h2>Hello with Vue CDN</h2>
            <vuejs-datepicker></vuejs-datepicker>

            <div class="example">
                <h3 id="example-1">#1 - Single select</h3>
                <div class="output">Data: {{ example1.value }}</div>
                <Multiselect v-model="example1.value" v-bind="example1"></Multiselect>
            </div>`
        });
        app.component('Multiselect', VueformMultiselect)
        app.mount("#app")
    </script>
</body>
</html>

In this scenario, I utilize CDNs for vuejs 3, vuejs-datepicker, and multiselect. The inclusion of the multiselect component was achieved through the command app.component('Multiselect', VueformMultiselect). By examining the corresponding JavaScript file, I located this code snippet for incorporating the functionality:

var VueformMultiselect=function(e,t).......

However, I encountered difficulty in adding the vuejs-datepicker component to my application as I could not find a similar declaration method. Can anyone provide guidance on how to incorporate the vuejs-datepicker component into my existing code?

Thank you

Answer №1

In Vue3, you won't be able to utilize the vuejs-datepicker. Instead, consider using vue3datepicker:

<div id="app"></div>
<script src="https://unpkg.com/vue@next"></script>
<script src="https://unpkg.com/vue3-date-time-picker@latest/dist/vue3-date-time-picker.min.js"></script>
<link rel="stylesheet" href="https://unpkg.com/vue3-date-time-picker@latest/dist/main.css">
<script type="text/javascript" src="https://unpkg.com/@vueform/multiselect"></script>
<link rel="stylesheet" type="text/css" href="https://unpkg.com/@vueform/multiselect/themes/default.css">
<script>
  const app = Vue.createApp({
      data: () => ({
          example1: {
            value: 0,
            options: ['Batman', 'Robin', 'Joker'],
          },
          selDate: null
      }),
      components: { Datepicker: Vue3DatePicker,  Multiselect: VueformMultiselect },
      template: 
        `<h2>Hello with Vue CDN</h2>
          <datepicker v-model="selDate"></datepicker>
          <div class="output">Data: {{ selDate }}</div>
          <div class="example">
              <h3 id="example-1">#1 - Single select</h3>
              <div class="output">Data: {{ example1.value }}</div>
              <Multiselect v-model="example1.value" v-bind="example1"></Multiselect>
          </div>`
  });
  app.mount("#app")
</script>

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

Tips for changing the state of a Jquery Mobile flip switch programmatically

I am encountering an issue with my jQuery Mobile flip toggle switches on my Android/iPad application. I need to be able to change their states dynamically using JavaScript. Despite trying various solutions mentioned in this thread (Change value of flip tog ...

Resetting the input field in React.js using Hooks on button click

My goal is to create an input field where users can type in information. When they click a button, the input is processed and backend operations are performed with the connected database. I am attempting to achieve this using a state hook: saving the input ...

Steps for dynamically loading a component in Vue

<template> <div> <v-container fluid id="main"> <v-card class="white lighten-4 elevation-3"> <li v-for="stop in stop_name_arr"> {{stop}} </li> <direct_bus_travel_time_in_ ...

Notification from Socket.io following completion of database update

Can messages be sent to all users when the admin makes changes to the database, for example using the alert function? Scenario: Users are browsing car offers and while doing so, the admin changes the prices of a few offers --> users receive notificatio ...

Why isn't Ajax sending the array to the Controller Action?

I have searched for solutions to similar questions, but I am still unable to make this work in my specific case. My project is based on ASP.NET MVC. The issue I am facing involves a report with 3 filters where only one value can be selected for Filters 1 ...

Iterating through a for loop in Angular2 to send multiple GET requests to a Django backend

Currently, I'm facing a challenge with performing multiple GET requests using Angular2 within a Django/Python environment. After successfully making an API request and retrieving a list of users to determine the current user's ID, I utilize a .f ...

What is the value of x in the equation 2 raised to the power of x equals 800

Similar Question: What is the reverse of Math.pow in JavaScript? 2^x=i If i is given, how can we determine x using Javascript? ...

Working with Three.js: Retrieving an object post-loading using GLTF Loader

Is there a method in three.js using the GLTF loader to access an object for transformations after it has been loaded? It seems like attempting this approach does not yield results gltf.scene.position.set(10,10,10) Sample Code: function getObject(){ ...

Creating a duplicate of a Flex object in HTML without the need to reinitialize

I'm currently developing a flash object that involves processing a large number of images. My goal is to load multiple flash objects on the same page in order to capture an image, make adjustments, and then display it within each flash object. Howeve ...

Achieving success with the "silent-scroll" technique

I've been struggling to implement the 'scroll-sneak' JavaScript code for quite some time now. This code is designed to prevent the page from jumping to the top when an anchor link is clicked, while still allowing the link to function as inte ...

Challenges encountered while developing Angular FormArrays: Managing value changes, applying validators, and resolving checkbox deselection

I am facing an issue with my Angular formArray of checkboxes. In order to ensure that at least one checkbox is selected, I have implemented a validator. However, there are two problems that I need to address: Firstly, when the last checkbox is selecte ...

Utilizing Material-UI List components within a Card component triggers all onClick events when the main expand function is activated

Need help with Material-UI, Meteor, and React I am trying to nest a drop down list with onTouchTap (or onClick) functions inside of a card component. While everything renders fine initially, I face an issue where all the onTouchTap events in the list tri ...

Incorporating the <script type="text/javascript" src="bootstrap-4.4.1/js/bootstrap.min.js"></script> file into the code

I am having trouble understanding the purpose of including 'bootstrap4.4.1/js/bootstrap.min.js' link in my HTML code within a script tag. Can someone please explain its significance? ...

Having trouble importing Angular flex-layout into my feature module

I'm facing an issue with Angular flex-layout in one of my modules. It works perfectly fine when I import flex-layout in the app module, but only for the app component. However, when I import flex-layout in another module, it doesn't seem to work ...

Is there a way to trigger the animation of this text effect only when the mouse is scrolled to that specific section?

Here is a cool typing text effect created using HTML, CSS, and JavaScript. Check out the code below: (function($) { var s, spanizeLetters = { settings: { letters: $('.js-spanize'), }, init: function() { ...

Looking for assistance with debugging form validation for a dropdown menu using JavaScript/jQuery

Here is the setup of my jsfiddle: http://jsfiddle.net/xCCA2/ My goal is to validate the size select dropdown when a form is submitted. If a valid selection is made, the form should be posted. If an invalid selection is made, I want an alert box to popup ...

issue with transparent html5

Here is the code snippet I am struggling with: function clear(){ context2D.clearRect(0, 0, canvas.width, canvas.height); } function drawCharacterRight(){ clear(); context2D.setTransform(1, 0.30, 1, -0.30, 10, 380);//having issues here c ...

How to efficiently manage multiple INSERT, SELECT, and UPDATE operations in mysql2 using nodejs

I am seeking guidance on how to approach a specific problem that I am facing. Due to my limited knowledge of databases, I am unsure of the best method to tackle this issue. The challenge I am dealing with involves receiving a 'large' amount of d ...

Sending a property to a function in Redux for action creation

I'm currently facing an issue with passing the ID number as a prop into my action creator function when using an onClick event. I've successfully used this syntax in the past with setState(), but for some reason it's not working for me now. ...

Request to access embedded server with CORS (unchangeable) restrictions

When working with HTML4, I didn't encounter any issues creating an XmlHttpRequest to fetch an AJAX packet. However, as I'm moving on to HTML5, I've come across the term cors (which is new to me). Given that the server I'm dealing with i ...