Need to process numbers in js in a HtmlDialog but js doesn't cope with SketchUp format length strings

Download your preferred version of vue.global.js 3.x.x from VUE CDN links - CDNPKG
Be sure to choose a stable release. For the later versions there is a problem with the REGEX optional flag ‘s’ not working with older versions of javascript.

Here’s a working HTML example.

<!doctype html>
<html lang = "en">
<head>
  <meta charset="UTF-8">
  <title>Document</title>
  <script src="https://unpkg.com/vue@3.2.29"></script>
</head>
<body>
  <div id='app'>
    {{ greeting }}
  </div>
  
  <script>
    Vue.createApp({
      data() {
        return {
          greeting: 'Hello World'
        };
      }        
    }).mount('#app');
  </script>
</body>
</html>

To use the local copy of vue.global.js we just need to change the source location:

<script src="js/vue.global.js"></script>

and the Sketchup Ruby script

dialog = UI::HtmlDialog.new(
{
  :dialog_title => "Dialog Example",
  :preferences_key => "com.sample.plugin",
  :scrollable => true,
  :resizable => true,
  :width => 600,
  :height => 400,
  :left => 100,
  :top => 100,
  :min_width => 50,
  :min_height => 50,
  :max_width =>1000,
  :max_height => 1000,
  :style => UI::HtmlDialog::STYLE_DIALOG
})
dialog.set_url('file:///c:/users/user/desktop/vue3.html')
dialog.show

Hope this helps.

1 Like

Yes sWilliams, that link is good, as it seems to be update regularly.
Been playing with Vue quite a bit. It has nice features indeed.
All references advocate to use Vue components. I wonder if they can be used within an extension?
I encountered security blocks. - “cross origin request not supported.

I believe that some features can only be delivered via an httpserver. Post a code snippet that throws the error and someone may try to find a workaround for you.

Hum… But since I’m adding Vue to dialogs of extensions and thinking about user and all their different setups, I would say Vue Components are ruled out.
So for now I stick to options api.

Update: And after long research, I could not find any equivalent to JS ‘onload’ but for Components. So this is a show stopper for me.
I must be missing something.

Update2: I was indeed missing an important fact. Vue is made to auto-update. So my concern was with image switching, and I found how to do it with v-bind.