How to use Vue JS on an particular page 🙏 #83
-
Hello, product.liquid product.liquid
..
...
...
export default {
data () {
return {
name: 'shopify-theme-lab',
},
mounted () {
axios
.get(`/products/${product_handle}.json`)
.then(response => (this.name = response))
},
methods: {
},
} When I try to do that the page become blank and nothing showing, I need you help 🙏🙏🙏🙏 |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
I have another issue, the Shopify liquid didn't recognize inside mixins, always returned string, I added a variable to the product.liquid let product_handle = '{{product.handle}}'; than I add it inside global.mixin.js mounted () {
axios
.get(`/products/${product_handle}.json`)
.then(response => (this.productjson = response))
}, I manage to get the data back but I always get an error message and I don't know how to fix it error 'product_handle' is not defined no-undef |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
First, that's not a good practice and second that doesn't work. Webpack can't see those script tags. Here's a basic example how one can achieve reactivity:
<template>
<div>
{{ currentVariantId }}
</div>
</template>
<script>
export default {
name: 'demoComponent',
props: {
currentVariantId: {
type: String,
required: true
}
}
}
</script>
<demo-component current-variant-id="{{ some-liquid-data }}"></demo-component> Here's another example but based on renderless-components: |
Beta Was this translation helpful? Give feedback.
First, that's not a good practice and second that doesn't work. Webpack can't see those script tags. Here's a basic example how one can achieve reactivity:
src/vue/components/render/demo.vue
:Here's another example but based on renderless-components: