How do I use a Vue 2 component in a HTML single file that uses Vue 3 UMD build

I’m trying to use https://vue-treeselect.js.org/ (multi-select component with nested options) in a Vue 3 single local HTML file (I don’t want to use the Vue CLI for this specific task), using the standalone UMD build Vue 2, it works as it follows (as showed in the docs):

<html>
  <head>
    <!-- include Vue 2.x -->
    <script src="https://cdn.jsdelivr.net/npm/vue@^2"></script>
    <!-- include vue-treeselect & its styles. you can change the version tag to better suit your needs. -->
    <script src="https://cdn.jsdelivr.net/npm/@riophae/vue-treeselect@^0.4.0/dist/vue-treeselect.umd.min.js"></script>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@riophae/vue-treeselect@^0.4.0/dist/vue-treeselect.min.css">
  </head>
  <body>
    <div id="app">
      <treeselect v-model="value" :multiple="true" :options="options" />
    </div>
  </body>
  <script>
    // register the component
    Vue.component('treeselect', VueTreeselect.Treeselect)

    new Vue({
      el: '#app',
      data: {
        // define the default value
        value: null,
        // define options
        options: [ {
          id: 'a',
          label: 'a',
          children: [ {
            id: 'aa',
            label: 'aa',
          }, {
            id: 'ab',
            label: 'ab',
          } ],
        }, {
          id: 'b',
          label: 'b',
        }, {
          id: 'c',
          label: 'c',
        } ],
      },
    })
  </script>
</html>

How can I do the same using the UMD build for Vue 3?

I tried it switching the script line from Vue 2 to Vue 3, and adding the value and option variables inside data() like this (but does not recognize the new treeselect tag):

<html>

<head>
    <!-- Vue 3 -->
    <script src="https://unpkg.com/vue@next"></script>
    <!-- include vue-treeselect & its styles. you can change the version tag to better suit your needs. -->
    <script src="https://cdn.jsdelivr.net/npm/@riophae/vue-treeselect@^0.4.0/dist/vue-treeselect.umd.min.js"></script>
    <link rel="stylesheet"
        href="https://cdn.jsdelivr.net/npm/@riophae/vue-treeselect@^0.4.0/dist/vue-treeselect.min.css">
</head>

<body>
    <div id="app">
        <treeselect v-model="value" :multiple="true" :options="options" />
    </div>
</body>

<script>

    const app = Vue.createApp({

        data() {
            return {
                value: null,
                // define options
                options: [{
                    id: 'a',
                    label: 'a',
                    children: [{
                        id: 'aa',
                        label: 'aa',
                    }, {
                        id: 'ab',
                        label: 'ab',
                    }],
                }, {
                    id: 'b',
                    label: 'b',
                }, {
                    id: 'c',
                    label: 'c',
                }],
            };
        }


    })

    app.component('treeselect', VueTreeselect.Treeselect)
    app.mount('#app')

</script>

</html>

131 thoughts on “How do I use a Vue 2 component in a HTML single file that uses Vue 3 UMD build”

  1. Hi everyone, it’s my first pay a quick visit at this web
    page, and article is actually fruitful in support of me,
    keep up posting these content.

    Reply
  2. Do you have a spam problem on this website; I also am a blogger, and
    I was wanting to know your situation; we have developed some
    nice methods and we are looking to exchange methods with
    other folks, be sure to shoot me an email if interested.

    Reply
  3. Hi, Neat post. There is an issue with your site in internet explorer, may check this?

    IE still is the marketplace chief and a big part of people will miss your fantastic writing due
    to this problem.

    Reply
  4. Everything wrote made a ton of sense. However,
    think about this, what if you added a little information? I am not saying your content is not good., however what if you
    added something that grabbed folk’s attention? I mean How do I use a Vue 2 component
    in a HTML single file that uses Vue 3 UMD build – JavaScript Help is a little plain. You
    ought to glance at Yahoo’s front page and watch how they create
    post titles to get viewers interested. You
    might add a related video or a picture or two to grab people interested about what
    you’ve written. In my opinion, it could bring your blog a little
    bit more interesting.

    Reply
  5. Greetings from Colorado! I’m bored at work so I decided to browse your
    blog on my iphone during lunch break. I really like the information you present here and can’t
    wait to take a look when I get home. I’m amazed at how fast your blog loaded on my phone ..
    I’m not even using WIFI, just 3G .. Anyways, great blog!

    Reply
  6. Hi there this is somewhat of off topic but I was wondering if
    blogs use WYSIWYG editors or if you have to manually code with HTML.
    I’m starting a blog soon but have no coding expertise so I
    wanted to get advice from someone with experience.
    Any help would be enormously appreciated!

    Reply
  7. Hi would you mind letting me know which web host you’re utilizing?

    I’ve loaded your blog in 3 different browsers and I must say this
    blog loads a lot quicker then most. Can you suggest
    a good hosting provider at a honest price? Many thanks, I appreciate it!

    Reply
  8. Hello there, I discovered your blog via Google at
    the same time as looking for a similar matter, your web site came up,
    it seems to be great. I have bookmarked it in my google bookmarks.

    Hello there, simply become aware of your blog via Google, and located that
    it’s really informative. I’m gonna be careful for brussels.

    I will appreciate in the event you continue this in future.

    Numerous people can be benefited from your writing.
    Cheers!

    Reply
  9. Hello there! I know this is kinda off topic but I’d figured
    I’d ask. Would you be interested in trading links or maybe guest
    authoring a blog article or vice-versa? My site addresses a lot of the same
    topics as yours and I feel we could greatly benefit from each
    other. If you’re interested feel free to shoot me an e-mail.

    I look forward to hearing from you! Excellent blog by the way!

    Reply
  10. I think this is among the most vital information for me.
    And i’m glad reading your article. But want to remark on some general things, The web site style
    is perfect, the articles is really great :
    D. Good job, cheers

    Reply
  11. I have been browsing online more than 2 hours today, yet I never found
    any interesting article like yours. It’s pretty worth enough for me.
    In my view, if all webmasters and bloggers made good content as
    you did, the internet will be a lot more useful than ever before.

    Reply
  12. Howdy would you mind letting me know which web host you’re
    working with? I’ve loaded your blog in 3 different
    web browsers and I must say this blog loads a lot quicker then most.

    Can you recommend a good web hosting provider at a reasonable price?
    Cheers, I appreciate it!

    Reply
  13. What i don’t realize is in reality how you are no longer actually
    much more well-favored than you might be right now.
    You are so intelligent. You understand therefore considerably relating to
    this topic, made me individually consider it from a lot of varied angles.

    Its like men and women aren’t fascinated unless it is one thing to accomplish with Girl gaga!
    Your individual stuffs outstanding. Always care for it up!

    Reply
  14. We absolutely love your blog and find almost all of your post’s to be exactly I’m looking for.

    Do you offer guest writers to write content for you personally?
    I wouldn’t mind creating a post or elaborating on most of the subjects you write regarding here.
    Again, awesome web log!

    Reply
  15. My developer is trying to convince me to move to .net from PHP.
    I have always disliked the idea because of the costs.
    But he’s tryiong none the less. I’ve been using Movable-type on several websites for about a year and am worried about switching to another platform.
    I have heard good things about blogengine.net.
    Is there a way I can transfer all my wordpress posts into it?
    Any kind of help would be really appreciated!

    Reply
  16. Wonderful beat ! I would like to apprentice while you amend your
    web site, how can i subscribe for a blog website?
    The account helped me a acceptable deal. I had been tiny bit acquainted of this your broadcast offered bright clear concept

    Reply
  17. Hey would you mind sharing which blog platform you’re working with?
    I’m looking to start my own blog soon but I’m having a hard time deciding between BlogEngine/Wordpress/B2evolution and
    Drupal. The reason I ask is because your layout seems different then most blogs and I’m looking for
    something unique. P.S Sorry for getting off-topic but I had to ask!

    Reply
  18. I am extremely impressed along with your writing talents as neatly as with the format on your blog.
    Is that this a paid subject or did you customize it yourself?
    Either way stay up the excellent high quality writing,
    it is uncommon to look a great weblog like this
    one nowadays..

    Reply
  19. I have been surfing online more than 3 hours today, yet I never
    found any interesting article like yours. It is pretty worth enough for me.
    In my view, if all website owners and bloggers made good content as you did, the net will be much more useful
    than ever before.

    Reply
  20. Hi fantastic website! Does running a blog similar to this require
    a large amount of work? I have no knowledge of
    programming but I was hoping to start my own blog soon. Anyway, if you have any suggestions or techniques for new blog owners please share.
    I know this is off topic however I just had to ask.
    Thanks a lot!

    Reply
  21. I am really impressed with your writing talents as well as with the format for your weblog.

    Is this a paid theme or did you modify it yourself?
    Either way stay up the excellent quality writing, it is rare to see a
    nice blog like this one nowadays..

    Reply
  22. I believe what you published was actually very logical.

    But, consider this, what if you were to write a killer post title?
    I am not saying your content isn’t good, but what if
    you added something to maybe grab folk’s attention? I mean How
    do I use a Vue 2 component in a HTML single file that uses
    Vue 3 UMD build – JavaScript Help is kinda boring.
    You ought to glance at Yahoo’s front page and note how they create news headlines
    to grab viewers interested. You might add a video or a related
    pic or two to get readers interested about what you’ve written. Just my opinion, it might make your blog a little livelier.

    Reply
  23. Do you mind if I quote a few of your posts as long
    as I provide credit and sources back to your weblog?
    My blog site is in the very same niche as yours and my visitors would really benefit from some of the information you provide here.
    Please let me know if this okay with you. Appreciate it!

    Reply
  24. Hi outstanding website! Does running a blog similar to this require
    a lot of work? I’ve absolutely no expertise in coding but I was hoping to start
    my own blog in the near future. Anyhow, if you have any suggestions or tips for new blog owners please share.

    I understand this is off subject however I simply wanted to ask.
    Thanks a lot!

    Reply
  25. Hmm it appears like your site ate my first comment (it was super
    long) so I guess I’ll just sum it up what I had written and say,
    I’m thoroughly enjoying your blog. I too am an aspiring blog blogger but I’m still new to the whole thing.
    Do you have any tips for newbie blog writers? I’d really
    appreciate it.

    Reply
  26. Thanks a lot for sharing this with all folks you really
    recognise what you are talking about! Bookmarked.
    Please additionally consult with my website =). We will have a link
    exchange contract between us

    Reply
  27. Superb website you have here but I was wanting to know
    if you knew of any message boards that cover the same topics discussed here?
    I’d really love to be a part of group where I can get opinions from other knowledgeable people
    that share the same interest. If you have any recommendations, please let me know.
    Thank you!

    Reply
  28. I do agree with all of the ideas you have offered for your post.
    They are really convincing and can certainly work.
    Nonetheless, the posts are very brief for starters. May just you please prolong them
    a bit from subsequent time? Thanks for the post.

    Reply
  29. Can I simply just say what a relief to find
    someone who actually knows what they are talking about
    on the web. You certainly realize how to bring a problem to light and make
    it important. More people must check this out and
    understand this side of the story. I can’t believe you are not more popular because you certainly have the gift.

    Reply
  30. You really make it seem so easy with your presentation but I
    find this topic to be really something which I think I would
    never understand. It seems too complex and very broad for me.
    I am looking forward for your next post, I will try to get the hang of it!

    Reply
  31. Simply want to say your article is as surprising. The clearness in your
    post is simply excellent and i can assume you are an expert on this subject.
    Fine with your permission let me to grab your RSS feed
    to keep up to date with forthcoming post. Thanks
    a million and please keep up the enjoyable work.

    Reply
  32. You really make it seem so easy with your presentation but I find
    this matter to be really something which I think I would
    never understand. It seems too complex and extremely broad for me.
    I am looking forward for your next post, I will try to get the
    hang of it!

    Reply
  33. Excellent items from you, man. I have bear in mind your stuff prior to and you are
    simply too magnificent. I really like what you’ve got right here,
    certainly like what you’re stating and the way in which in which you assert it.
    You make it entertaining and you still care for to
    stay it wise. I can not wait to read far more from you.
    This is actually a great web site.

    Reply
  34. After looking over a few of the articles on your web page, I really appreciate your way of writing a blog.
    I added it to my bookmark site list and will be checking back
    soon. Take a look at my website as well and let me know how you feel.

    Reply
  35. It’s a shame you don’t have a donate button! I’d most certainly donate to this
    excellent blog! I guess for now i’ll settle for book-marking and adding your
    RSS feed to my Google account. I look forward to brand new updates and will talk about this site with my Facebook group.
    Chat soon!

    Reply
  36. Does your website have a contact page? I’m having problems locating
    it but, I’d like to shoot you an e-mail. I’ve got some suggestions for your
    blog you might be interested in hearing. Either way, great website and I look forward to seeing it grow over time.

    Reply
  37. I was wondering if you ever thought of changing the page
    layout of your website? Its very well written; I love what
    youve got to say. But maybe you could a little more in the way of content so people could connect
    with it better. Youve got an awful lot of text for only having one or two pictures.
    Maybe you could space it out better?

    Reply
  38. Greetings from Idaho! I’m bored to death
    at work so I decided to check out your blog on my iphone during
    lunch break. I love the knowledge you provide here and can’t wait to take a
    look when I get home. I’m shocked at how fast your blog loaded
    on my cell phone .. I’m not even using WIFI, just
    3G .. Anyways, great blog!

    Reply
  39. Thanks for a marvelous posting! I really enjoyed reading it, you’re
    a great author. I will remember to bookmark your blog and will come back from now on. I want to encourage one to continue your great posts, have a nice day!

    Reply
  40. Hi there! This post could not be written any better!
    Reading this post reminds me of my previous room mate! He always kept talking about this.
    I will forward this write-up to him. Pretty sure he will
    have a good read. Thanks for sharing!

    Reply
  41. Your style is very unique compared to other folks I have read stuff from.
    Many thanks for posting when you’ve got the opportunity, Guess I will
    just bookmark this page.

    Reply
  42. Hello just wanted to give you a quick heads up and let you
    know a few of the images aren’t loading correctly. I’m not
    sure why but I think its a linking issue. I’ve tried it
    in two different internet browsers and both
    show the same results.

    Reply
  43. Simply wish to say your article is as astonishing.
    The clearness in your post is just spectacular and i can assume you are an expert
    on this subject. Fine with your permission allow me to grab your feed to keep updated with forthcoming post.

    Thanks a million and please keep up the gratifying work.

    Reply
  44. I will immediately snatch your rss as I can’t to find your email subscription link
    or newsletter service. Do you’ve any? Kindly permit me recognise so that I may subscribe.
    Thanks.

    Reply

Leave a Comment