How to implement the widget with Vue.js application

Rodrigo Asai
Rodrigo Asai
  • Updated

In order to implement the widget using a application with  Vue.js, please follow the steps: 

  1. Look for a file named default.vue (this code can be added to other layout files as well).
    Inside the export default block, add the following code:

    Before:

    <script>
    import AppHeader from "@/components/AppHeader.vue";
    import AppFooter from "@/components/AppFooter.vue";

    export default {

        name: "Default",
        components: {
          AppHeader,
          AppFooter
        }
    }
    </script>

    After:

    <script>
    import AppHeader from "@/components/AppHeader.vue";
    import AppFooter from "@/components/AppFooter.vue";

    export default {
             name: "Default",
             components: {
                  AppHeader,
                  AppFooter
            },
           mounted() {
               let userwayscript = document.createElement('script');
               userwayscript.setAttribute('src', 'https://cdn.userway.org/widget.js');
               userwayscript.setAttribute('data-account', 'your account ID');
               document.head.appendChild(userwayscript);
           }
    }
    </script>

  2. Modify the value of data-account attribute to your own account ID.
  3. Save the file and test the widget on your website.