Troubleshooting
Vue
All Vue-related files are auto-loaded by webpack with require.contextopen in new window - Vue components, Vuex modules, as well as mixins and directives with
global
in their filename. Everything is defined insrc/main.js
Vue components inside
.liquid
files can only be used in a non-self-closing kebab case manner.
<kebab-case></kebab-case>
1
- If a
name
is defined inside a.vue
file, it can be referenced byname
otherwise the component will be named after the file path starting from thesrc/vue/components/
directory.
<script>
// src/vue/components/render/my-component.vue
export default {
name: 'MyComponent' // not required
}
</script>
1
2
3
4
5
6
7
2
3
4
5
6
7
<!-- has a name defined -->
<my-component></my-component>
<!-- has no name defined -->
<render-my-component></render-my-component>
1
2
3
4
5
2
3
4
5
- Use
raw
tags to output unparsed code inside of.liquid
files.
{% raw %}{{ vueVariable }}{% endraw %}
1
- Don't place regular
<style>
and<script>
tags inside the Vue instance. They will be removed on mount. Use Vue<component>
tags instead and specify the'is'
prop.
<div id="app">
<component is="style">
...
<componet>
<component is="script">
...
</componet>
</div>
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
Renderless
components require one single root element.
<rendereless-component v-slot="{ data }">
<div>
...
</div>
<rendereless-component>
1
2
3
4
5
2
3
4
5
- If you want to pass an entire Shopify Drop (Object) as a prop, you have to convert the Drop first to
JSON
and then replace all double quotes with single quotes.
<component
:shopify-data="{{ product | json | replace: '"', "'" }}"
></component>
1
2
3
2
3
- Not all Drops can be converted to
JSON
though if you get an{"error":"json not allowed for this object"}
you'll have to pass the values in question individually.
<component
:shopify-data="{
productTitle: '{{ product.title }}',
productId: '{{ product.id }}'
}"
></component>
1
2
3
4
5
6
2
3
4
5
6
- Whenever you use
Vue
functionality inside a Shopifysection
add thevue
keyword to the section's wrapper classes. It fixes rendering issues in the theme editor as well as during development-reloading.
<!-- shopify/sections/section-file.liquid -->
...
{% schema %}
{
"class": "vue-section"
}
{% endschema %}
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9