Experience the Power of Vue.js in Your Shopify Store

I have encountered an issue while attempting to integrate 3 custom modals into Shopify. Upon implementing them, I received the following error in the console (not originating from my Vue files, but rather from the Shopify template):

[Vue warn]: Error compiling template:
Templates should only be responsible for mapping the state to the UI. Avoid placing tags with side-effects in your templates, such as <style>, as they will not be parsed.

20 |            </div>
21 |          </div>
22 |        </div><style data-shopify="">
   |              ^^^^^^^^^^^^^^^^^^^^^^^
23 |   

The primary index shopify structure appears as follows:

<body class="template-{{ template | split: '.' | first }}">
<div id="app-vue">
    <a class="in-page-link skip-link" href="#MainContent">{{ 'general.accessibility.skip_to_content' | t }}</a>

    <div id="SearchDrawer" class="search-bar drawer--top" role="dialog" aria-modal="true" aria-label="{{ 'general.search.placeholder' | t }}">
        <div class="search-bar__table">
            <div class="search-bar__form-wrapper">
                <form class="search" action="{{ routes.search_url }}" method="get" role="search">
                    <input class="search__input" type="search" name="q" value="{{ search.terms | escape }}" placeholder="{{ 'general.search.placeholder' | t }}" aria-label="{{ 'general.search.placeholder' | t }}">
                    <button class="search-bar__submit btn--link" type="submit">
                        {% include 'icon-search' %}
                        <span class="icon__fallback-text">{{ 'general.search.submit' | t }}</span>
                    </button>
                </form>
            </div>
            <div class="search-bar__table-cell">
                <button type="button" class="btn--link js-drawer-close">
                    {% include 'icon-close' %}
                    <span class="icon__fallback-text">{{ 'general.search.close' | t }}</span>
                </button>
            </div>
        </div>
    </div>

    {%- if settings.enable_ajax -%}
    {% include 'cart-popup' %}
    {%- endif -%}

    {% section 'header' %}

    <div class="page-container" id="PageContainer">

        <main class="main-content js-focus-hidden" id="MainContent" role="main" tabindex="-1">
            {{ content_for_layout }}
        </main>

        {% section 'footer' %}

        <div id="slideshow-info" class="visually-hidden" aria-hidden="true">
            {{- 'sections.slideshow.navigation_instructions' | t -}}
        </div>

    </div>

    <ul hidden>
        <li id="a11y-refresh-page-message">{{ 'general.accessibility.refresh_page' | t }}</li>
        <li id="a11y-selection-message">{{ 'general.accessibility.selection_help' | t }}</li>
    </ul>

    <edit-subscription-modal></edit-subscription-modal>
    <before-cancel-subscription-modal></before-cancel-subscription-modal>
    <cancel-subscription-modal></cancel-subscription-modal>
</div>

Within the code snippet above, the app-vue id is utilized and the modals are included at the bottom:

 <edit-subscription-modal></edit-subscription-modal>
 <before-cancel-subscription-modal></before-cancel-subscription-modal>
 <cancel-subscription-modal></cancel-subscription-modal>

Subsequently, I reference the modals in another file via this component:

<account shopify-id="{{ customer.id }}"></account>

To address the error and ensure that it doesn't read all Shopify tags, the modals must be appropriately defined within the index file.

Thank you!

Answer №1

When linking external sections or snippets within a vue-app container, it is important to ensure that they do not contain any elements such as "style", "script", or other tags that are not supported by the vue template syntax.

For integrating Vue into Shopify themes, another approach involves using precompiled single file components. I have written an article with ready-to-use examples on this topic. If you are interested, please take a look: Vue.js components in Shopify themes

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

One of the challenges faced with using AngularJS is that it can often

I have a piece of code that is functioning correctly: angular.module('foo', []).config( function($locationProvider) { $locationProvider.html5Mode(true); } ); However, when the code is minified, it gets compressed and looks like this: a ...

JavaScript format nested data structure

For my latest project, I am working on a blog using Strapi combined with Nuxt. To fetch the categories and articles data for my blog, I send a JSON object from my front-end application using Axios. { "data": [ { "id": 1, ...

Personalized modify and remove elements on a row of the DataGrid material-ui version 5 component when hovered over

In my React Js app, I am utilizing Material UI components or MUI v5 as the UI library for my project. Within the DataGrid/DataGridPro component, I am implementing a custom edit and delete row feature. The requirement is to display edit and delete icons w ...

Leveraging the Meteor Framework for Application Monitoring

Exploring the potential of utilizing Meteor Framework in a Monitoring Application. Scenario: A Java Application operating within a cluster produces data, which is then visualized by a Web Application (charts, etc.) Currently, this process involves using ...

Unit testing in JavaScript has its limitations, one of which is the inability to verify if a

Currently, I am working with an Angular application that includes a simple directive called animate. My goal is to use Jasmine to verify if the slideDown method is being called. Below is the current setup of my directive: animateDirective var animate = f ...

Switching the children image source by hovering over the parent element

I have a React component that functions as a card containing a title and an image. I want the image to change upon hovering over the entire card, rather than just the img element itself. While CSS and the background property could achieve this, I prefer k ...

Tips for confirming receipt of a message through socket.io on the client side

What is the process for ensuring that a message sent using the socket.io library has been successfully received by the client? Does socket.io provide a specific method for confirming receipt? Appreciate any insights you can provide! ...

Leveraging the power of JavaScript to reveal concealed div elements

I've got a collection of divs (five in total) with a hidden class applied to them in my CSS stylesheet. Each div also has its own unique ID. My goal is to use JavaScript to reveal these divs one by one. Here's an example of what I'm looking ...

Utilizing a child component in React to trigger a function on its sibling component

Trying to put this question into words is proving to be a challenge. I am wondering in React, if there is a way for a child component that is deeply nested (2 levels deep from the parent) to trigger a function on another component that it has a sibling rel ...

Having trouble getting Vue.js to cooperate with a brand new Laravel 5.8 setup?

I set up a fresh Laravel project using laravel new sample. Then I executed npm install followed by npm run dev. Next, I modified the welcome.blade.php file as shown below: <!DOCTYPE html> <html> <head> <script type="text/j ...

Skip using bootstrap-vue icons by utilizing the Webpack IgnorePlugin

After analyzing with Webpack bundle analyzer, I discovered that the icons from the bootstrap-vue package are a whopping 535kb in size. Knowing this, I've decided not to utilize them in my project. I attempted to exclude the entire package using a web ...

Turn off scrolling for the body content without removing the scrollbar visibility

Whenever I click a thumbnail, a div overlay box appears on top: .view-overlay { display:none; position:fixed; top:0; left:0; right:0; bottom:0; overflow-y:scroll; background-color:rgba(0,0,0,0.7); z-index:999; } Some browsers with non-f ...

Create an element that can be dragged without the need to specify its position as absolute

I am having an issue where elements I want to drag on a canvas are not appearing next to each other as expected. Instead, they are overlapping: To make these elements draggable, I am utilizing the dragElement(element) function from https://www.w3schools.c ...

Determine the size of an SVG while taking into consideration any strokes applied

Is there a way to seamlessly position an SVG in the corner of a div, despite having a dynamically generated stroke? Calculating the distance to the outermost part of the border proves difficult when dealing with irregular shapes like stars. Here's my ...

Determining the Last Modified Date for a Sitemap using Javascript

I am trying to replicate the date format shown within <lastmod></lastmod> tags in a sitemap.xml file. How can I do this? The desired output is as follows: <lastmod>2016-01-21EEST18:01:18+03:00</lastmod> It appears that 'EEST ...

``There seems to be a malfunction with the modal feature in the asp.net

Within my strongly typed view, I have a loop that iterates over a list of objects fetched from a database. Each object is displayed within a jumbotron element, accompanied by a button labeled "Had role before". When this button is clicked, a modal opens wh ...

Displaying or concealing HTML elements using AngularJS while a modal is open

Looking for a way to display a loading spinner icon on my page when a user triggers a button that opens a modal, and then have the spinner disappear once the modal is open and its content has loaded. Currently, I've managed to make the spinner show up ...

Utilizing Bootstrap to allow for seamless text wrapping around a text input field

I am trying to implement a "fill-in-the-blank" feature using Bootstrap, where users need to enter a missing word to complete a sentence. Is there a way to align the text input horizontally and have the rest of the sentence wrap around it? This is my curr ...

Laravel: The current configuration does not support the experimental syntax 'classProperties' at this time

When compiling my javascript files using npm run dev, I encountered a warning in my resource/app.js file where I require my custom validation script. The warning stated the following: Module build failed (from ./node_modules/babel-loader/lib/index.js): Syn ...

The Angular scope remains stagnant even after applying changes

Having trouble updating a variable in the ng-repeat loop <div ng-controller="MapViewCtrl"> <a class="item item-avatar" ng-href="#/event/tabs/mapView" > <img src="img/location.jpg"/> <span cl ...