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

After clicking the submit button, make sure to automatically fill in all empty input fields

I am currently working on a form that includes various input types such as text fields, radio buttons, select dropdowns, and text areas. The form is displayed in a table format with an option to add additional rows. One issue I have encountered is that us ...

Arranging HTML elements with jQuery - the existing script flips back and forth

I have created a code snippet on CodePen that showcases a feature of the website I am currently developing: http://codepen.io/barrychapman/pen/BzJGbg?editors=1010 Upon loading the page, you will notice 6 boxes. The first box is active, while the remaining ...

Creating a JavaScript function that responds to multiple click events

Can someone please help me out? I have the link to the output of my work below using JavaScript and HTML: My goal is for only one circle to be active when clicked, while the others are disabled. Currently, when I click on a circle and then another one, bo ...

Issue: It is necessary to utilize the `@babel/plugin-transform-runtime` plugin if you have set `babelHelpers` to "runtime" when using npm link

My situation involves having two interconnected React libraries: project-ui and propert-utils. project-ui relies on propert-utils, and the latter is installed within the former. "devDependencies": { "@company/project-utils": "gi ...

The active class in the Bootstrap carousel is not updating when trying to change

I am struggling to make the Twitter Bootstrap carousel function properly. Although the slides automatically change after the default timeout, the indicators do not switch the active class, resulting in my carousel failing to transition between slides. Ini ...

Tips for verifying whether a variable is a node?

Curiosity strikes me: how can I determine if the variable myVar is a node? I could simply check myVar.nodeType, but that might be misleading with something like {nodeType:1} So, naturally, I start to wonder if there's a way to do this instead: myVa ...

Tips for ensuring the vertical scroll bar is always visible on a div element

I need help with maintaining a vertical scroll bar on a div regardless of its height. .myclass { overflow-y: scroll; } <div class="myclass"> Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the in ...

Ways to troubleshoot and fix the problem of encountering an "Internal Server Error" when sending emails with nodeMailer in node.js

When attempting to send a confirmation email using nodemailer, I encountered an internet server error in production when allowing insecure apps for Gmail accounts, although it works fine locally. Any suggestions on how to resolve this issue? router.post(& ...

Is it possible to set up the material-ui datepicker to allow for the selection of dates spanning across multiple months without losing visibility of the current month?

Is it possible to choose dates within the same calendar week, regardless of whether they fall in different calendar months? For instance, selecting Friday from the previous month when the new month begins on a Saturday. To illustrate my point, let's ...

Exploring nested static properties within TypeScript class structures

Check out this piece of code: class Hey { static a: string static b: string static c: string static setABC(a: string, b: string, c: string) { this.a = a this.b = b this.c = c return this } } class A { static prop1: Hey static ...

The addScript feature seems to be experiencing difficulties upon the initial website load

Currently, I am utilizing the jquery.flexslider plugin and it is performing well. However, I have a specific requirement where I do not want to load the plugin for screens that are smaller than 600px. After experimenting with various scripts, I have final ...

Choosing a recently inserted row in jqGrid

After reloading the grid, I am trying to select the newly added row, which is always added at the end. However, it seems impossible to do so after the reload. Is there a reliable way to select the last row after reloading the grid? The current code I have ...

Saving the author of a message from one function and transferring it to another

I'm currently working on a Discord bot that manages tickets as applications. I've almost completed it, but I want the bot to log the closed ticket when the -close command is used. I've experimented with different approaches, such as using a ...

Aurelia's numerous applications spread across various pages

Currently, I am in the process of finalizing the initial release of a large-scale website built using PHP (Phalcon), MySQL, and JQuery. The technology stack may be a bit outdated, but it was originally prototyped years ago and due to various circumstances, ...

Unable to retrieve coverage report using rewire and cross-env

My challenge lies in obtaining the coverage report using nyc, which works flawlessly without the cross-env plugin. cross-env NODE_ENV=test nyc mocha --ui bdd --reporter spec --colors --require babel-core/register tests --recursive When executing this com ...

Starting over fresh after clearing the interval

Visit the test site Is there a way to reset the animation back to the beginning once it reaches the last image? I've attempted the code below, but it doesn't seem to bring it back to the first image. $(document).ready(function () { window. ...

How to execute a JavaScript function within PHP code

Hey there, seeking some assistance. On my main page index.php, I have a simple js function named function1() that opens test.php as a pop-up window when clicked. The content in this pop-up window comes from another page called p1.php. Now, I need to set it ...

Merge the xAxis functionality with Highcharts

My issue involves a chart generated by highcharts.js. The problem arises with a line chart consisting of 5 values (5 points), each displayed on the xAxis as follows: from value 1 to value 2: 0, 0.25, 0.5, 0.75, 1. I am looking to modify this display and re ...

What is the best way to choose just one value from an option that includes two variables?

I have a list of properties with numbers and names displayed in my form options. <b-col md="3"> <b-form-group :label="$t('departmentNumber')"> <b-form-select vuelidate v-model="$v.consumptionCon ...

Using the `preventDefault` method within an `onclick` function nested inside another `onclick

I am currently working on an example in react.js <Card onClick="(e)=>{e.preventDefault(); goPage()}"> <Card.body> <Media> <img width={64} height={64} className="mr-3" ...