
Vantea Smart
Emmanuel González A.
Junior Web Developer
Agustín T. Rocha
Junior Web Developer
- Tailwind
- Shopify
- Vue 3 Composition Api
- Vue Router
- Vuex
- Consejos, recomendaciones y dudas
¿Qué es?
“Tailwind CSS es un Framework de CSS que brinda clases útiles para nuestro desarrollo web. ”
Muestra de codigo
| <template> |
| <div class="py-3 px-8 bg-green-500 |
| text-center cursor-pointer rounded-xl"> |
| <p class="text-center text-white |
| font-semibold uppercase"> |
| De lujo |
| </p> |
| </div> |
| </template> |
Instalación
| npm install tailwindcss |
| |
| ----- |
| |
| <link href="https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css" rel="stylesheet"> |
| npm install tailwindcss |
| |
| ----- |
| |
| <link href="https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css" rel="stylesheet"> |
| npm install tailwindcss |
| |
| ----- |
| |
| <link href="https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css" rel="stylesheet"> |
| npm install tailwindcss |
| |
| ----- |
| |
| <link href="https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css" rel="stylesheet"> |
Archivo config
| module.exports = { |
| important: true, |
| prefix: 'tw-', |
| purge: { |
| enabled: false, |
| content: [ |
| './assets/layout/*.liquid', |
| './assets/templates/*.liquid', |
| './assets/sections/*.liquid', |
| './assets/snippets/*.liquid', |
| ], |
| }, |
| darkMode: false, // or 'media' or 'class' |
| theme: { |
| screens: { |
| 'sm': '640px', |
| 'md': '768px', |
| 'lg': '1024px', |
| 'xl': '1280px', |
| '2xl': '1600px' |
| }, |
| extend: { |
| fontFamily: { |
| 'recoletaAlt': 'RecoletaAlt, serif', |
| }, |
| height: { |
| 76: '19rem', |
| 96: '25rem', |
| 160: '40rem', |
| }, |
| minWidth: { |
| 80: '20rem', |
| 84: '21rem', |
| 88: '22rem', |
| 92: '23rem', |
| 96: '24rem', |
| 100: '25rem' |
| }, |
| width: { |
| 75: '18.75rem', |
| 84: '21rem', |
| 88: '22rem', |
| 92: '23rem', |
| 96: '24rem', |
| 100: '25rem' |
| }, |
| borderRadius: { |
| 'lg-xl': '0.625rem' |
| }, |
| colors: { |
| primary: { |
| DEFAULT: "#58B98C" |
| }, |
| secondary: { |
| DEFAULT: "#F7796A" |
| }, |
| neutral: { |
| black: "#212322", |
| semiblack: "#1D1D1B", |
| dark: "#85888E", |
| DEFAULT: "#9D9E9E", |
| optional: "#DADADA", |
| light: "#F0F1F5", |
| extraLight: "#f7f7f7", |
| } |
| } |
| } |
| }, |
| variants: { |
| extend: { |
| fontWeight: ['hover'], |
| cursor: ['hover'], |
| boxShadow: ['hover'], |
| display: ['group-hover'], |
| margin: ['first', 'last'], |
| borderWidth: ['first', 'last'], |
| borderRadius: ['first', 'last'], |
| borderColor: ['first', 'last','focus-within'], |
| width: ['first, last'], |
| height: ['first, last'], |
| backgroundPosition: ['first, last'] |
| } |
| }, |
| plugins: [], |
| } |
| module.exports = { |
| important: true, |
| prefix: 'tw-', |
| purge: { |
| enabled: false, |
| content: [ |
| './assets/layout/*.liquid', |
| './assets/templates/*.liquid', |
| './assets/sections/*.liquid', |
| './assets/snippets/*.liquid', |
| ], |
| }, |
| darkMode: false, // or 'media' or 'class' |
| theme: { |
| screens: { |
| 'sm': '640px', |
| 'md': '768px', |
| 'lg': '1024px', |
| 'xl': '1280px', |
| '2xl': '1600px' |
| }, |
| extend: { |
| fontFamily: { |
| 'recoletaAlt': 'RecoletaAlt, serif', |
| }, |
| height: { |
| 76: '19rem', |
| 96: '25rem', |
| 160: '40rem', |
| }, |
| minWidth: { |
| 80: '20rem', |
| 84: '21rem', |
| 88: '22rem', |
| 92: '23rem', |
| 96: '24rem', |
| 100: '25rem' |
| }, |
| width: { |
| 75: '18.75rem', |
| 84: '21rem', |
| 88: '22rem', |
| 92: '23rem', |
| 96: '24rem', |
| 100: '25rem' |
| }, |
| borderRadius: { |
| 'lg-xl': '0.625rem' |
| }, |
| colors: { |
| primary: { |
| DEFAULT: "#58B98C" |
| }, |
| secondary: { |
| DEFAULT: "#F7796A" |
| }, |
| neutral: { |
| black: "#212322", |
| semiblack: "#1D1D1B", |
| dark: "#85888E", |
| DEFAULT: "#9D9E9E", |
| optional: "#DADADA", |
| light: "#F0F1F5", |
| extraLight: "#f7f7f7", |
| } |
| } |
| } |
| }, |
| variants: { |
| extend: { |
| fontWeight: ['hover'], |
| cursor: ['hover'], |
| boxShadow: ['hover'], |
| display: ['group-hover'], |
| margin: ['first', 'last'], |
| borderWidth: ['first', 'last'], |
| borderRadius: ['first', 'last'], |
| borderColor: ['first', 'last','focus-within'], |
| width: ['first, last'], |
| height: ['first, last'], |
| backgroundPosition: ['first, last'] |
| } |
| }, |
| plugins: [], |
| } |
| module.exports = { |
| important: true, |
| prefix: 'tw-', |
| purge: { |
| enabled: false, |
| content: [ |
| './assets/layout/*.liquid', |
| './assets/templates/*.liquid', |
| './assets/sections/*.liquid', |
| './assets/snippets/*.liquid', |
| ], |
| }, |
| darkMode: false, // or 'media' or 'class' |
| theme: { |
| screens: { |
| 'sm': '640px', |
| 'md': '768px', |
| 'lg': '1024px', |
| 'xl': '1280px', |
| '2xl': '1600px' |
| }, |
| extend: { |
| fontFamily: { |
| 'recoletaAlt': 'RecoletaAlt, serif', |
| }, |
| height: { |
| 76: '19rem', |
| 96: '25rem', |
| 160: '40rem', |
| }, |
| minWidth: { |
| 80: '20rem', |
| 84: '21rem', |
| 88: '22rem', |
| 92: '23rem', |
| 96: '24rem', |
| 100: '25rem' |
| }, |
| width: { |
| 75: '18.75rem', |
| 84: '21rem', |
| 88: '22rem', |
| 92: '23rem', |
| 96: '24rem', |
| 100: '25rem' |
| }, |
| borderRadius: { |
| 'lg-xl': '0.625rem' |
| }, |
| colors: { |
| primary: { |
| DEFAULT: "#58B98C" |
| }, |
| secondary: { |
| DEFAULT: "#F7796A" |
| }, |
| neutral: { |
| black: "#212322", |
| semiblack: "#1D1D1B", |
| dark: "#85888E", |
| DEFAULT: "#9D9E9E", |
| optional: "#DADADA", |
| light: "#F0F1F5", |
| extraLight: "#f7f7f7", |
| } |
| } |
| } |
| }, |
| variants: { |
| extend: { |
| fontWeight: ['hover'], |
| cursor: ['hover'], |
| boxShadow: ['hover'], |
| display: ['group-hover'], |
| margin: ['first', 'last'], |
| borderWidth: ['first', 'last'], |
| borderRadius: ['first', 'last'], |
| borderColor: ['first', 'last','focus-within'], |
| width: ['first, last'], |
| height: ['first, last'], |
| backgroundPosition: ['first, last'] |
| } |
| }, |
| plugins: [], |
| } |
| module.exports = { |
| important: true, |
| prefix: 'tw-', |
| purge: { |
| enabled: false, |
| content: [ |
| './assets/layout/*.liquid', |
| './assets/templates/*.liquid', |
| './assets/sections/*.liquid', |
| './assets/snippets/*.liquid', |
| ], |
| }, |
| darkMode: false, // or 'media' or 'class' |
| theme: { |
| screens: { |
| 'sm': '640px', |
| 'md': '768px', |
| 'lg': '1024px', |
| 'xl': '1280px', |
| '2xl': '1600px' |
| }, |
| extend: { |
| fontFamily: { |
| 'recoletaAlt': 'RecoletaAlt, serif', |
| }, |
| height: { |
| 76: '19rem', |
| 96: '25rem', |
| 160: '40rem', |
| }, |
| minWidth: { |
| 80: '20rem', |
| 84: '21rem', |
| 88: '22rem', |
| 92: '23rem', |
| 96: '24rem', |
| 100: '25rem' |
| }, |
| width: { |
| 75: '18.75rem', |
| 84: '21rem', |
| 88: '22rem', |
| 92: '23rem', |
| 96: '24rem', |
| 100: '25rem' |
| }, |
| borderRadius: { |
| 'lg-xl': '0.625rem' |
| }, |
| colors: { |
| primary: { |
| DEFAULT: "#58B98C" |
| }, |
| secondary: { |
| DEFAULT: "#F7796A" |
| }, |
| neutral: { |
| black: "#212322", |
| semiblack: "#1D1D1B", |
| dark: "#85888E", |
| DEFAULT: "#9D9E9E", |
| optional: "#DADADA", |
| light: "#F0F1F5", |
| extraLight: "#f7f7f7", |
| } |
| } |
| } |
| }, |
| variants: { |
| extend: { |
| fontWeight: ['hover'], |
| cursor: ['hover'], |
| boxShadow: ['hover'], |
| display: ['group-hover'], |
| margin: ['first', 'last'], |
| borderWidth: ['first', 'last'], |
| borderRadius: ['first', 'last'], |
| borderColor: ['first', 'last','focus-within'], |
| width: ['first, last'], |
| height: ['first, last'], |
| backgroundPosition: ['first, last'] |
| } |
| }, |
| plugins: [], |
| } |
| module.exports = { |
| important: true, |
| prefix: 'tw-', |
| purge: { |
| enabled: false, |
| content: [ |
| './assets/layout/*.liquid', |
| './assets/templates/*.liquid', |
| './assets/sections/*.liquid', |
| './assets/snippets/*.liquid', |
| ], |
| }, |
| darkMode: false, // or 'media' or 'class' |
| theme: { |
| screens: { |
| 'sm': '640px', |
| 'md': '768px', |
| 'lg': '1024px', |
| 'xl': '1280px', |
| '2xl': '1600px' |
| }, |
| extend: { |
| fontFamily: { |
| 'recoletaAlt': 'RecoletaAlt, serif', |
| }, |
| height: { |
| 76: '19rem', |
| 96: '25rem', |
| 160: '40rem', |
| }, |
| minWidth: { |
| 80: '20rem', |
| 84: '21rem', |
| 88: '22rem', |
| 92: '23rem', |
| 96: '24rem', |
| 100: '25rem' |
| }, |
| width: { |
| 75: '18.75rem', |
| 84: '21rem', |
| 88: '22rem', |
| 92: '23rem', |
| 96: '24rem', |
| 100: '25rem' |
| }, |
| borderRadius: { |
| 'lg-xl': '0.625rem' |
| }, |
| colors: { |
| primary: { |
| DEFAULT: "#58B98C" |
| }, |
| secondary: { |
| DEFAULT: "#F7796A" |
| }, |
| neutral: { |
| black: "#212322", |
| semiblack: "#1D1D1B", |
| dark: "#85888E", |
| DEFAULT: "#9D9E9E", |
| optional: "#DADADA", |
| light: "#F0F1F5", |
| extraLight: "#f7f7f7", |
| } |
| } |
| } |
| }, |
| variants: { |
| extend: { |
| fontWeight: ['hover'], |
| cursor: ['hover'], |
| boxShadow: ['hover'], |
| display: ['group-hover'], |
| margin: ['first', 'last'], |
| borderWidth: ['first', 'last'], |
| borderRadius: ['first', 'last'], |
| borderColor: ['first', 'last','focus-within'], |
| width: ['first, last'], |
| height: ['first, last'], |
| backgroundPosition: ['first, last'] |
| } |
| }, |
| plugins: [], |
| } |
| module.exports = { |
| important: true, |
| prefix: 'tw-', |
| purge: { |
| enabled: false, |
| content: [ |
| './assets/layout/*.liquid', |
| './assets/templates/*.liquid', |
| './assets/sections/*.liquid', |
| './assets/snippets/*.liquid', |
| ], |
| }, |
| darkMode: false, // or 'media' or 'class' |
| theme: { |
| screens: { |
| 'sm': '640px', |
| 'md': '768px', |
| 'lg': '1024px', |
| 'xl': '1280px', |
| '2xl': '1600px' |
| }, |
| extend: { |
| fontFamily: { |
| 'recoletaAlt': 'RecoletaAlt, serif', |
| }, |
| height: { |
| 76: '19rem', |
| 96: '25rem', |
| 160: '40rem', |
| }, |
| minWidth: { |
| 80: '20rem', |
| 84: '21rem', |
| 88: '22rem', |
| 92: '23rem', |
| 96: '24rem', |
| 100: '25rem' |
| }, |
| width: { |
| 75: '18.75rem', |
| 84: '21rem', |
| 88: '22rem', |
| 92: '23rem', |
| 96: '24rem', |
| 100: '25rem' |
| }, |
| borderRadius: { |
| 'lg-xl': '0.625rem' |
| }, |
| colors: { |
| primary: { |
| DEFAULT: "#58B98C" |
| }, |
| secondary: { |
| DEFAULT: "#F7796A" |
| }, |
| neutral: { |
| black: "#212322", |
| semiblack: "#1D1D1B", |
| dark: "#85888E", |
| DEFAULT: "#9D9E9E", |
| optional: "#DADADA", |
| light: "#F0F1F5", |
| extraLight: "#f7f7f7", |
| } |
| } |
| } |
| }, |
| variants: { |
| extend: { |
| fontWeight: ['hover'], |
| cursor: ['hover'], |
| boxShadow: ['hover'], |
| display: ['group-hover'], |
| margin: ['first', 'last'], |
| borderWidth: ['first', 'last'], |
| borderRadius: ['first', 'last'], |
| borderColor: ['first', 'last','focus-within'], |
| width: ['first, last'], |
| height: ['first, last'], |
| backgroundPosition: ['first, last'] |
| } |
| }, |
| plugins: [], |
| } |
| module.exports = { |
| important: true, |
| prefix: 'tw-', |
| purge: { |
| enabled: false, |
| content: [ |
| './assets/layout/*.liquid', |
| './assets/templates/*.liquid', |
| './assets/sections/*.liquid', |
| './assets/snippets/*.liquid', |
| ], |
| }, |
| darkMode: false, // or 'media' or 'class' |
| theme: { |
| screens: { |
| 'sm': '640px', |
| 'md': '768px', |
| 'lg': '1024px', |
| 'xl': '1280px', |
| '2xl': '1600px' |
| }, |
| extend: { |
| fontFamily: { |
| 'recoletaAlt': 'RecoletaAlt, serif', |
| }, |
| height: { |
| 76: '19rem', |
| 96: '25rem', |
| 160: '40rem', |
| }, |
| minWidth: { |
| 80: '20rem', |
| 84: '21rem', |
| 88: '22rem', |
| 92: '23rem', |
| 96: '24rem', |
| 100: '25rem' |
| }, |
| width: { |
| 75: '18.75rem', |
| 84: '21rem', |
| 88: '22rem', |
| 92: '23rem', |
| 96: '24rem', |
| 100: '25rem' |
| }, |
| borderRadius: { |
| 'lg-xl': '0.625rem' |
| }, |
| colors: { |
| primary: { |
| DEFAULT: "#58B98C" |
| }, |
| secondary: { |
| DEFAULT: "#F7796A" |
| }, |
| neutral: { |
| black: "#212322", |
| semiblack: "#1D1D1B", |
| dark: "#85888E", |
| DEFAULT: "#9D9E9E", |
| optional: "#DADADA", |
| light: "#F0F1F5", |
| extraLight: "#f7f7f7", |
| } |
| } |
| } |
| }, |
| variants: { |
| extend: { |
| fontWeight: ['hover'], |
| cursor: ['hover'], |
| boxShadow: ['hover'], |
| display: ['group-hover'], |
| margin: ['first', 'last'], |
| borderWidth: ['first', 'last'], |
| borderRadius: ['first', 'last'], |
| borderColor: ['first', 'last','focus-within'], |
| width: ['first, last'], |
| height: ['first, last'], |
| backgroundPosition: ['first, last'] |
| } |
| }, |
| plugins: [], |
| } |
| module.exports = { |
| important: true, |
| prefix: 'tw-', |
| purge: { |
| enabled: false, |
| content: [ |
| './assets/layout/*.liquid', |
| './assets/templates/*.liquid', |
| './assets/sections/*.liquid', |
| './assets/snippets/*.liquid', |
| ], |
| }, |
| darkMode: false, // or 'media' or 'class' |
| theme: { |
| screens: { |
| 'sm': '640px', |
| 'md': '768px', |
| 'lg': '1024px', |
| 'xl': '1280px', |
| '2xl': '1600px' |
| }, |
| extend: { |
| fontFamily: { |
| 'recoletaAlt': 'RecoletaAlt, serif', |
| }, |
| height: { |
| 76: '19rem', |
| 96: '25rem', |
| 160: '40rem', |
| }, |
| minWidth: { |
| 80: '20rem', |
| 84: '21rem', |
| 88: '22rem', |
| 92: '23rem', |
| 96: '24rem', |
| 100: '25rem' |
| }, |
| width: { |
| 75: '18.75rem', |
| 84: '21rem', |
| 88: '22rem', |
| 92: '23rem', |
| 96: '24rem', |
| 100: '25rem' |
| }, |
| borderRadius: { |
| 'lg-xl': '0.625rem' |
| }, |
| colors: { |
| primary: { |
| DEFAULT: "#58B98C" |
| }, |
| secondary: { |
| DEFAULT: "#F7796A" |
| }, |
| neutral: { |
| black: "#212322", |
| semiblack: "#1D1D1B", |
| dark: "#85888E", |
| DEFAULT: "#9D9E9E", |
| optional: "#DADADA", |
| light: "#F0F1F5", |
| extraLight: "#f7f7f7", |
| } |
| } |
| } |
| }, |
| variants: { |
| extend: { |
| fontWeight: ['hover'], |
| cursor: ['hover'], |
| boxShadow: ['hover'], |
| display: ['group-hover'], |
| margin: ['first', 'last'], |
| borderWidth: ['first', 'last'], |
| borderRadius: ['first', 'last'], |
| borderColor: ['first', 'last','focus-within'], |
| width: ['first, last'], |
| height: ['first, last'], |
| backgroundPosition: ['first, last'] |
| } |
| }, |
| plugins: [], |
| } |
¿Qué es?
“Shopify es un CMS para eCommerce que permite diseñar tu tienda online al gusto sin necesidad de tener conocimientos de programación ”
¿Qué es Liquid?
Muestra de codigo
| {% if section.settings.enable_dots %} |
| <ul class="controls"> |
| {% for block in section.blocks %} |
| <li class="controlDot |
| {% if forloop.first %}active{% endif %}"></li> |
| {% endfor %} |
| </ul> |
| {% endif %} |
| {% if section.settings.enable_arrows %} |
| <div class="nextControl--hero-banner" |
| onclick="nextSlide()"></div> |
| {% endif %} |


option api example
| import ... |
| export default { |
| name: "", |
| components: { ... }, |
| props: { ... }, |
| data () { |
| return { |
| products: [], |
| customers: [], |
| searchQuery: '' |
| } |
| }, |
| computed: { |
| filteredProducts () { ... }, |
| filteredCustomers () { ... } |
| }, |
| watch: { |
| products: 'getProductsStock' |
| }, |
| methods: { |
| getProducts () { ... } |
| getCustomers () { ... } |
| }, |
| mounted () { |
| this.getProducts() |
| } |
| } |
| import ... |
| export default { |
| name: "", |
| components: { ... }, |
| props: { ... }, |
| data () { |
| return { |
| products: [], |
| customers: [], |
| searchQuery: '' |
| } |
| }, |
| computed: { |
| filteredProducts () { ... }, |
| filteredCustomers () { ... } |
| }, |
| watch: { |
| products: 'getProductsStock' |
| }, |
| methods: { |
| getProducts () { ... } |
| getCustomers () { ... } |
| }, |
| mounted () { |
| this.getProducts() |
| } |
| } |
| import ... |
| export default { |
| name: "", |
| components: { ... }, |
| props: { ... }, |
| data () { |
| return { |
| products: [], |
| customers: [], |
| searchQuery: '' |
| } |
| }, |
| computed: { |
| filteredProducts () { ... }, |
| filteredCustomers () { ... } |
| }, |
| watch: { |
| products: 'getProductsStock' |
| }, |
| methods: { |
| getProducts () { ... } |
| getCustomers () { ... } |
| }, |
| mounted () { |
| this.getProducts() |
| } |
| } |
| import ... |
| export default { |
| name: "", |
| components: { ... }, |
| props: { ... }, |
| data () { |
| return { |
| products: [], |
| customers: [], |
| searchQuery: '' |
| } |
| }, |
| computed: { |
| filteredProducts () { ... }, |
| filteredCustomers () { ... } |
| }, |
| watch: { |
| products: 'getProductsStock' |
| }, |
| methods: { |
| getProducts () { ... } |
| getCustomers () { ... } |
| }, |
| mounted () { |
| this.getProducts() |
| } |
| } |
| import ... |
| export default { |
| name: "", |
| components: { ... }, |
| props: { ... }, |
| data () { |
| return { |
| products: [], |
| customers: [], |
| searchQuery: '' |
| } |
| }, |
| computed: { |
| filteredProducts () { ... }, |
| filteredCustomers () { ... } |
| }, |
| watch: { |
| products: 'getProductsStock' |
| }, |
| methods: { |
| getProducts () { ... } |
| getCustomers () { ... } |
| }, |
| mounted () { |
| this.getProducts() |
| } |
| } |
| import ... |
| export default { |
| name: "", |
| components: { ... }, |
| props: { ... }, |
| data () { |
| return { |
| products: [], |
| customers: [], |
| searchQuery: '' |
| } |
| }, |
| computed: { |
| filteredProducts () { ... }, |
| filteredCustomers () { ... } |
| }, |
| watch: { |
| products: 'getProductsStock' |
| }, |
| methods: { |
| getProducts () { ... } |
| getCustomers () { ... } |
| }, |
| mounted () { |
| this.getProducts() |
| } |
| } |
| import ... |
| export default { |
| name: "", |
| components: { ... }, |
| props: { ... }, |
| data () { |
| return { |
| products: [], |
| customers: [], |
| searchQuery: '' |
| } |
| }, |
| computed: { |
| filteredProducts () { ... }, |
| filteredCustomers () { ... } |
| }, |
| watch: { |
| products: 'getProductsStock' |
| }, |
| methods: { |
| getProducts () { ... } |
| getCustomers () { ... } |
| }, |
| mounted () { |
| this.getProducts() |
| } |
| } |
| import ... |
| export default { |
| name: "", |
| components: { ... }, |
| props: { ... }, |
| data () { |
| return { |
| products: [], |
| customers: [], |
| searchQuery: '' |
| } |
| }, |
| computed: { |
| filteredProducts () { ... }, |
| filteredCustomers () { ... } |
| }, |
| watch: { |
| products: 'getProductsStock' |
| }, |
| methods: { |
| getProducts () { ... } |
| getCustomers () { ... } |
| }, |
| mounted () { |
| this.getProducts() |
| } |
| } |
| import ... |
| export default { |
| name: "", |
| components: { ... }, |
| props: { ... }, |
| data () { |
| return { |
| products: [], |
| customers: [], |
| searchQuery: '' |
| } |
| }, |
| computed: { |
| filteredProducts () { ... }, |
| filteredCustomers () { ... } |
| }, |
| watch: { |
| products: 'getProductsStock' |
| }, |
| methods: { |
| getProducts () { ... } |
| getCustomers () { ... } |
| }, |
| mounted () { |
| this.getProducts() |
| } |
| } |
composition api example
| import { ref, computed, watch } from "vue"; |
| export default { |
| name: { ... }, |
| props: { ... }, |
| setup(){ |
| const products = ref([]); |
| const filteredProducts = computed(() => { ... }); |
| const getProducts = () => { ... }); |
| watch(() => products => ... ); |
| |
| const customers = ref([]); |
| const filteredCustomers = () => { ... }); |
| const getCustomers = () => { ... }); |
| |
| getProducts(); |
| |
| return { |
| filteredProducts, |
| filteredCustomers |
| } |
| } |
| } |
| import { ref, computed, watch } from "vue"; |
| export default { |
| name: { ... }, |
| props: { ... }, |
| setup(){ |
| const products = ref([]); |
| const filteredProducts = computed(() => { ... }); |
| const getProducts = () => { ... }); |
| watch(() => products => ... ); |
| |
| const customers = ref([]); |
| const filteredCustomers = () => { ... }); |
| const getCustomers = () => { ... }); |
| |
| getProducts(); |
| |
| return { |
| filteredProducts, |
| filteredCustomers |
| } |
| } |
| } |
| import { ref, computed, watch } from "vue"; |
| export default { |
| name: { ... }, |
| props: { ... }, |
| setup(){ |
| const products = ref([]); |
| const filteredProducts = computed(() => { ... }); |
| const getProducts = () => { ... }); |
| watch(() => products => ... ); |
| |
| const customers = ref([]); |
| const filteredCustomers = () => { ... }); |
| const getCustomers = () => { ... }); |
| |
| getProducts(); |
| |
| return { |
| filteredProducts, |
| filteredCustomers |
| } |
| } |
| } |
| import { ref, computed, watch } from "vue"; |
| export default { |
| name: { ... }, |
| props: { ... }, |
| setup(){ |
| const products = ref([]); |
| const filteredProducts = computed(() => { ... }); |
| const getProducts = () => { ... }); |
| watch(() => products => ... ); |
| |
| const customers = ref([]); |
| const filteredCustomers = () => { ... }); |
| const getCustomers = () => { ... }); |
| |
| getProducts(); |
| |
| return { |
| filteredProducts, |
| filteredCustomers |
| } |
| } |
| } |
| import { ref, computed, watch } from "vue"; |
| export default { |
| name: { ... }, |
| props: { ... }, |
| setup(){ |
| const products = ref([]); |
| const filteredProducts = computed(() => { ... }); |
| const getProducts = () => { ... }); |
| watch(() => products => ... ); |
| |
| const customers = ref([]); |
| const filteredCustomers = () => { ... }); |
| const getCustomers = () => { ... }); |
| |
| getProducts(); |
| |
| return { |
| filteredProducts, |
| filteredCustomers |
| } |
| } |
| } |
| import { ref, computed, watch } from "vue"; |
| export default { |
| name: { ... }, |
| props: { ... }, |
| setup(){ |
| const products = ref([]); |
| const filteredProducts = computed(() => { ... }); |
| const getProducts = () => { ... }); |
| watch(() => products => ... ); |
| |
| const customers = ref([]); |
| const filteredCustomers = () => { ... }); |
| const getCustomers = () => { ... }); |
| |
| getProducts(); |
| |
| return { |
| filteredProducts, |
| filteredCustomers |
| } |
| } |
| } |
| import { ref, computed, watch } from "vue"; |
| export default { |
| name: { ... }, |
| props: { ... }, |
| setup(){ |
| const products = ref([]); |
| const filteredProducts = computed(() => { ... }); |
| const getProducts = () => { ... }); |
| watch(() => products => ... ); |
| |
| const customers = ref([]); |
| const filteredCustomers = () => { ... }); |
| const getCustomers = () => { ... }); |
| |
| getProducts(); |
| |
| return { |
| filteredProducts, |
| filteredCustomers |
| } |
| } |
| } |
| import { ref, computed, watch } from "vue"; |
| export default { |
| name: { ... }, |
| props: { ... }, |
| setup(){ |
| const products = ref([]); |
| const filteredProducts = computed(() => { ... }); |
| const getProducts = () => { ... }); |
| watch(() => products => ... ); |
| |
| const customers = ref([]); |
| const filteredCustomers = () => { ... }); |
| const getCustomers = () => { ... }); |
| |
| getProducts(); |
| |
| return { |
| filteredProducts, |
| filteredCustomers |
| } |
| } |
| } |
| import { ref, computed, watch } from "vue"; |
| export default { |
| name: { ... }, |
| props: { ... }, |
| setup(){ |
| const products = ref([]); |
| const filteredProducts = computed(() => { ... }); |
| const getProducts = () => { ... }); |
| watch(() => products => ... ); |
| |
| const customers = ref([]); |
| const filteredCustomers = () => { ... }); |
| const getCustomers = () => { ... }); |
| |
| getProducts(); |
| |
| return { |
| filteredProducts, |
| filteredCustomers |
| } |
| } |
| } |
| import { ref, computed, watch } from "vue"; |
| export default { |
| name: { ... }, |
| props: { ... }, |
| setup(){ |
| const products = ref([]); |
| const filteredProducts = computed(() => { ... }); |
| const getProducts = () => { ... }); |
| watch(() => products => ... ); |
| |
| const customers = ref([]); |
| const filteredCustomers = () => { ... }); |
| const getCustomers = () => { ... }); |
| |
| getProducts(); |
| |
| return { |
| filteredProducts, |
| filteredCustomers |
| } |
| } |
| } |


Single Page Application (Spa)

Instalación
| npm install vue-router@4 --save |
/src/router/index.js
| import { createWebHistory, createRouter } from "vue-router"; |
| import Home from "@/components/Home.vue"; |
| import Category from "@/components/Category.vue"; |
| import MyProducts from "@/components/MyProducts.vue"; |
| |
| const routes = [ |
| { |
| path: "/", |
| name: "Home", |
| component: Home, |
| }, |
| { |
| path: "/categories/:id", |
| name: "Category", |
| component: Category, |
| props: true |
| }, |
| { |
| path: "/my-products", |
| name: "MyProducts", |
| component: MyProducts, |
| } |
| ]; |
| |
| const router = createRouter({ |
| history: createWebHistory(), |
| routes, |
| }); |
| |
| export default router; |
| import { createWebHistory, createRouter } from "vue-router"; |
| import Home from "@/components/Home.vue"; |
| import Category from "@/components/Category.vue"; |
| import MyProducts from "@/components/MyProducts.vue"; |
| |
| const routes = [ |
| { |
| path: "/", |
| name: "Home", |
| component: Home, |
| }, |
| { |
| path: "/categories/:id", |
| name: "Category", |
| component: Category, |
| props: true |
| }, |
| { |
| path: "/my-products", |
| name: "MyProducts", |
| component: MyProducts, |
| } |
| ]; |
| |
| const router = createRouter({ |
| history: createWebHistory(), |
| routes, |
| }); |
| |
| export default router; |
| import { createWebHistory, createRouter } from "vue-router"; |
| import Home from "@/components/Home.vue"; |
| import Category from "@/components/Category.vue"; |
| import MyProducts from "@/components/MyProducts.vue"; |
| |
| const routes = [ |
| { |
| path: "/", |
| name: "Home", |
| component: Home, |
| }, |
| { |
| path: "/categories/:id", |
| name: "Category", |
| component: Category, |
| props: true |
| }, |
| { |
| path: "/my-products", |
| name: "MyProducts", |
| component: MyProducts, |
| } |
| ]; |
| |
| const router = createRouter({ |
| history: createWebHistory(), |
| routes, |
| }); |
| |
| export default router; |
| import { createWebHistory, createRouter } from "vue-router"; |
| import Home from "@/components/Home.vue"; |
| import Category from "@/components/Category.vue"; |
| import MyProducts from "@/components/MyProducts.vue"; |
| |
| const routes = [ |
| { |
| path: "/", |
| name: "Home", |
| component: Home, |
| }, |
| { |
| path: "/categories/:id", |
| name: "Category", |
| component: Category, |
| props: true |
| }, |
| { |
| path: "/my-products", |
| name: "MyProducts", |
| component: MyProducts, |
| } |
| ]; |
| |
| const router = createRouter({ |
| history: createWebHistory(), |
| routes, |
| }); |
| |
| export default router; |
| import { createWebHistory, createRouter } from "vue-router"; |
| import Home from "@/components/Home.vue"; |
| import Category from "@/components/Category.vue"; |
| import MyProducts from "@/components/MyProducts.vue"; |
| |
| const routes = [ |
| { |
| path: "/", |
| name: "Home", |
| component: Home, |
| }, |
| { |
| path: "/categories/:id", |
| name: "Category", |
| component: Category, |
| props: true |
| }, |
| { |
| path: "/my-products", |
| name: "MyProducts", |
| component: MyProducts, |
| } |
| ]; |
| |
| const router = createRouter({ |
| history: createWebHistory(), |
| routes, |
| }); |
| |
| export default router; |
| import { createWebHistory, createRouter } from "vue-router"; |
| import Home from "@/components/Home.vue"; |
| import Category from "@/components/Category.vue"; |
| import MyProducts from "@/components/MyProducts.vue"; |
| |
| const routes = [ |
| { |
| path: "/", |
| name: "Home", |
| component: Home, |
| }, |
| { |
| path: "/categories/:id", |
| name: "Category", |
| component: Category, |
| props: true |
| }, |
| { |
| path: "/my-products", |
| name: "MyProducts", |
| component: MyProducts, |
| } |
| ]; |
| |
| const router = createRouter({ |
| history: createWebHistory(), |
| routes, |
| }); |
| |
| export default router; |
| import { createWebHistory, createRouter } from "vue-router"; |
| import Home from "@/components/Home.vue"; |
| import Category from "@/components/Category.vue"; |
| import MyProducts from "@/components/MyProducts.vue"; |
| |
| const routes = [ |
| { |
| path: "/", |
| name: "Home", |
| component: Home, |
| }, |
| { |
| path: "/categories/:id", |
| name: "Category", |
| component: Category, |
| props: true |
| }, |
| { |
| path: "/my-products", |
| name: "MyProducts", |
| component: MyProducts, |
| } |
| ]; |
| |
| const router = createRouter({ |
| history: createWebHistory(), |
| routes, |
| }); |
| |
| export default router; |
| import { createWebHistory, createRouter } from "vue-router"; |
| import Home from "@/components/Home.vue"; |
| import Category from "@/components/Category.vue"; |
| import MyProducts from "@/components/MyProducts.vue"; |
| |
| const routes = [ |
| { |
| path: "/", |
| name: "Home", |
| component: Home, |
| }, |
| { |
| path: "/categories/:id", |
| name: "Category", |
| component: Category, |
| props: true |
| }, |
| { |
| path: "/my-products", |
| name: "MyProducts", |
| component: MyProducts, |
| } |
| ]; |
| |
| const router = createRouter({ |
| history: createWebHistory(), |
| routes, |
| }); |
| |
| export default router; |
| import { createWebHistory, createRouter } from "vue-router"; |
| import Home from "@/components/Home.vue"; |
| import Category from "@/components/Category.vue"; |
| import MyProducts from "@/components/MyProducts.vue"; |
| |
| const routes = [ |
| { |
| path: "/", |
| name: "Home", |
| component: Home, |
| }, |
| { |
| path: "/categories/:id", |
| name: "Category", |
| component: Category, |
| props: true |
| }, |
| { |
| path: "/my-products", |
| name: "MyProducts", |
| component: MyProducts, |
| } |
| ]; |
| |
| const router = createRouter({ |
| history: createWebHistory(), |
| routes, |
| }); |
| |
| export default router; |
| import { createWebHistory, createRouter } from "vue-router"; |
| import Home from "@/components/Home.vue"; |
| import Category from "@/components/Category.vue"; |
| import MyProducts from "@/components/MyProducts.vue"; |
| |
| const routes = [ |
| { |
| path: "/", |
| name: "Home", |
| component: Home, |
| }, |
| { |
| path: "/categories/:id", |
| name: "Category", |
| component: Category, |
| props: true |
| }, |
| { |
| path: "/my-products", |
| name: "MyProducts", |
| component: MyProducts, |
| } |
| ]; |
| |
| const router = createRouter({ |
| history: createWebHistory(), |
| routes, |
| }); |
| |
| export default router; |
| import { createWebHistory, createRouter } from "vue-router"; |
| import Home from "@/components/Home.vue"; |
| import Category from "@/components/Category.vue"; |
| import MyProducts from "@/components/MyProducts.vue"; |
| |
| const routes = [ |
| { |
| path: "/", |
| name: "Home", |
| component: Home, |
| }, |
| { |
| path: "/categories/:id", |
| name: "Category", |
| component: Category, |
| props: true |
| }, |
| { |
| path: "/my-products", |
| name: "MyProducts", |
| component: MyProducts, |
| } |
| ]; |
| |
| const router = createRouter({ |
| history: createWebHistory(), |
| routes, |
| }); |
| |
| export default router; |
| import { createWebHistory, createRouter } from "vue-router"; |
| import Home from "@/components/Home.vue"; |
| import Category from "@/components/Category.vue"; |
| import MyProducts from "@/components/MyProducts.vue"; |
| |
| const routes = [ |
| { |
| path: "/", |
| name: "Home", |
| component: Home, |
| }, |
| { |
| path: "/categories/:id", |
| name: "Category", |
| component: Category, |
| props: true |
| }, |
| { |
| path: "/my-products", |
| name: "MyProducts", |
| component: MyProducts, |
| } |
| ]; |
| |
| const router = createRouter({ |
| history: createWebHistory(), |
| routes, |
| }); |
| |
| export default router; |
/src/main.js
| import { createApp } from 'vue' |
| import App from './App.vue' |
| import router from './router' |
| |
| createApp(App).use(router).mount('#app') |
| import { createApp } from 'vue' |
| import App from './App.vue' |
| import router from './router' |
| |
| createApp(App).use(router).mount('#app') |
| import { createApp } from 'vue' |
| import App from './App.vue' |
| import router from './router' |
| |
| createApp(App).use(router).mount('#app') |
| import { createApp } from 'vue' |
| import App from './App.vue' |
| import router from './router' |
| |
| createApp(App).use(router).mount('#app') |
| import { createApp } from 'vue' |
| import App from './App.vue' |
| import router from './router' |
| |
| createApp(App).use(router).mount('#app') |
| import { createApp } from 'vue' |
| import App from './App.vue' |
| import router from './router' |
| |
| createApp(App).use(router).mount('#app') |
/src/main.js
| <template> |
| <div id="nav"> |
| <router-link to="/categories/156"> |
| Agua |
| </router-link> |
| <router-link to="/categories/163"> |
| Isotónico y energético |
| </router-link> |
| <router-link to="/categories/158"> |
| Refresco de cola |
| </router-link> |
| <router-link to="/categories/159"> |
| Refresco de naranja y limón |
| </router-link> |
| </div> |
| <router-view /> |
| </template> |
| <template> |
| <div id="nav"> |
| <router-link to="/categories/156"> |
| Agua |
| </router-link> |
| <router-link to="/categories/163"> |
| Isotónico y energético |
| </router-link> |
| <router-link to="/categories/158"> |
| Refresco de cola |
| </router-link> |
| <router-link to="/categories/159"> |
| Refresco de naranja y limón |
| </router-link> |
| </div> |
| <router-view /> |
| </template> |
| <template> |
| <div id="nav"> |
| <router-link to="/categories/156"> |
| Agua |
| </router-link> |
| <router-link to="/categories/163"> |
| Isotónico y energético |
| </router-link> |
| <router-link to="/categories/158"> |
| Refresco de cola |
| </router-link> |
| <router-link to="/categories/159"> |
| Refresco de naranja y limón |
| </router-link> |
| </div> |
| <router-view /> |
| </template> |
| <template> |
| <div id="nav"> |
| <router-link to="/categories/156"> |
| Agua |
| </router-link> |
| <router-link to="/categories/163"> |
| Isotónico y energético |
| </router-link> |
| <router-link to="/categories/158"> |
| Refresco de cola |
| </router-link> |
| <router-link to="/categories/159"> |
| Refresco de naranja y limón |
| </router-link> |
| </div> |
| <router-view /> |
| </template> |
| <template> |
| <div id="nav"> |
| <router-link to="/categories/156"> |
| Agua |
| </router-link> |
| <router-link to="/categories/163"> |
| Isotónico y energético |
| </router-link> |
| <router-link to="/categories/158"> |
| Refresco de cola |
| </router-link> |
| <router-link to="/categories/159"> |
| Refresco de naranja y limón |
| </router-link> |
| </div> |
| <router-view /> |
| </template> |
| <template> |
| <div id="nav"> |
| <router-link to="/categories/156"> |
| Agua |
| </router-link> |
| <router-link to="/categories/163"> |
| Isotónico y energético |
| </router-link> |
| <router-link to="/categories/158"> |
| Refresco de cola |
| </router-link> |
| <router-link to="/categories/159"> |
| Refresco de naranja y limón |
| </router-link> |
| </div> |
| <router-view /> |
| </template> |
| <template> |
| <div id="nav"> |
| <router-link to="/categories/156"> |
| Agua |
| </router-link> |
| <router-link to="/categories/163"> |
| Isotónico y energético |
| </router-link> |
| <router-link to="/categories/158"> |
| Refresco de cola |
| </router-link> |
| <router-link to="/categories/159"> |
| Refresco de naranja y limón |
| </router-link> |
| </div> |
| <router-view /> |
| </template> |
src/components/category.vue
| <template> |
| <div |
| v-for="{id, title, image, price, description} in products" |
| :key="id"> |
| <h1>{{ title }}</h1> |
| <img :src="image" :alt="title"/> |
| <h3> {{ price }} </h3> |
| <p> {{ description }}</p> |
| </div> |
| </template> |
| <script> |
| import { computed } from "vue"; |
| export default { |
| name: "category", |
| props: { |
| id: { |
| type: Number, |
| required: true |
| } |
| }, |
| setup(props) { |
| const products = computed(() => |
| fetch("api/v1/categories/" + props.id) |
| .then((data) => data.json()); |
| return { |
| products |
| } |
| } |
| } |
| <template> |
| <div |
| v-for="{id, title, image, price, description} in products" |
| :key="id"> |
| <h1>{{ title }}</h1> |
| <img :src="image" :alt="title"/> |
| <h3> {{ price }} </h3> |
| <p> {{ description }}</p> |
| </div> |
| </template> |
| <script> |
| import { computed } from "vue"; |
| export default { |
| name: "category", |
| props: { |
| id: { |
| type: Number, |
| required: true |
| } |
| }, |
| setup(props) { |
| const products = computed(() => |
| fetch("api/v1/categories/" + props.id) |
| .then((data) => data.json()); |
| return { |
| products |
| } |
| } |
| } |
| <template> |
| <div |
| v-for="{id, title, image, price, description} in products" |
| :key="id"> |
| <h1>{{ title }}</h1> |
| <img :src="image" :alt="title"/> |
| <h3> {{ price }} </h3> |
| <p> {{ description }}</p> |
| </div> |
| </template> |
| <script> |
| import { computed } from "vue"; |
| export default { |
| name: "category", |
| props: { |
| id: { |
| type: Number, |
| required: true |
| } |
| }, |
| setup(props) { |
| const products = computed(() => |
| fetch("api/v1/categories/" + props.id) |
| .then((data) => data.json()); |
| return { |
| products |
| } |
| } |
| } |
| <template> |
| <div |
| v-for="{id, title, image, price, description} in products" |
| :key="id"> |
| <h1>{{ title }}</h1> |
| <img :src="image" :alt="title"/> |
| <h3> {{ price }} </h3> |
| <p> {{ description }}</p> |
| </div> |
| </template> |
| <script> |
| import { computed } from "vue"; |
| export default { |
| name: "category", |
| props: { |
| id: { |
| type: Number, |
| required: true |
| } |
| }, |
| setup(props) { |
| const products = computed(() => |
| fetch("api/v1/categories/" + props.id) |
| .then((data) => data.json()); |
| return { |
| products |
| } |
| } |
| } |
| <template> |
| <div |
| v-for="{id, title, image, price, description} in products" |
| :key="id"> |
| <h1>{{ title }}</h1> |
| <img :src="image" :alt="title"/> |
| <h3> {{ price }} </h3> |
| <p> {{ description }}</p> |
| </div> |
| </template> |
| <script> |
| import { computed } from "vue"; |
| export default { |
| name: "category", |
| props: { |
| id: { |
| type: Number, |
| required: true |
| } |
| }, |
| setup(props) { |
| const products = computed(() => |
| fetch("api/v1/categories/" + props.id) |
| .then((data) => data.json()); |
| return { |
| products |
| } |
| } |
| } |
| <template> |
| <div |
| v-for="{id, title, image, price, description} in products" |
| :key="id"> |
| <h1>{{ title }}</h1> |
| <img :src="image" :alt="title"/> |
| <h3> {{ price }} </h3> |
| <p> {{ description }}</p> |
| </div> |
| </template> |
| <script> |
| import { computed } from "vue"; |
| export default { |
| name: "category", |
| props: { |
| id: { |
| type: Number, |
| required: true |
| } |
| }, |
| setup(props) { |
| const products = computed(() => |
| fetch("api/v1/categories/" + props.id) |
| .then((data) => data.json()); |
| return { |
| products |
| } |
| } |
| } |
| <template> |
| <div |
| v-for="{id, title, image, price, description} in products" |
| :key="id"> |
| <h1>{{ title }}</h1> |
| <img :src="image" :alt="title"/> |
| <h3> {{ price }} </h3> |
| <p> {{ description }}</p> |
| </div> |
| </template> |
| <script> |
| import { computed } from "vue"; |
| export default { |
| name: "category", |
| props: { |
| id: { |
| type: Number, |
| required: true |
| } |
| }, |
| setup(props) { |
| const products = computed(() => |
| fetch("api/v1/categories/" + props.id) |
| .then((data) => data.json()); |
| return { |
| products |
| } |
| } |
| } |
| <template> |
| <div |
| v-for="{id, title, image, price, description} in products" |
| :key="id"> |
| <h1>{{ title }}</h1> |
| <img :src="image" :alt="title"/> |
| <h3> {{ price }} </h3> |
| <p> {{ description }}</p> |
| </div> |
| </template> |
| <script> |
| import { computed } from "vue"; |
| export default { |
| name: "category", |
| props: { |
| id: { |
| type: Number, |
| required: true |
| } |
| }, |
| setup(props) { |
| const products = computed(() => |
| fetch("api/v1/categories/" + props.id) |
| .then((data) => data.json()); |
| return { |
| products |
| } |
| } |
| } |
| <template> |
| <div |
| v-for="{id, title, image, price, description} in products" |
| :key="id"> |
| <h1>{{ title }}</h1> |
| <img :src="image" :alt="title"/> |
| <h3> {{ price }} </h3> |
| <p> {{ description }}</p> |
| </div> |
| </template> |
| <script> |
| import { computed } from "vue"; |
| export default { |
| name: "category", |
| props: { |
| id: { |
| type: Number, |
| required: true |
| } |
| }, |
| setup(props) { |
| const products = computed(() => |
| fetch("api/v1/categories/" + props.id) |
| .then((data) => data.json()); |
| return { |
| products |
| } |
| } |
| } |
| <template> |
| <div |
| v-for="{id, title, image, price, description} in products" |
| :key="id"> |
| <h1>{{ title }}</h1> |
| <img :src="image" :alt="title"/> |
| <h3> {{ price }} </h3> |
| <p> {{ description }}</p> |
| </div> |
| </template> |
| <script> |
| import { computed } from "vue"; |
| export default { |
| name: "category", |
| props: { |
| id: { |
| type: Number, |
| required: true |
| } |
| }, |
| setup(props) { |
| const products = computed(() => |
| fetch("api/v1/categories/" + props.id) |
| .then((data) => data.json()); |
| return { |
| products |
| } |
| } |
| } |
| <template> |
| <div |
| v-for="{id, title, image, price, description} in products" |
| :key="id"> |
| <h1>{{ title }}</h1> |
| <img :src="image" :alt="title"/> |
| <h3> {{ price }} </h3> |
| <p> {{ description }}</p> |
| </div> |
| </template> |
| <script> |
| import { computed } from "vue"; |
| export default { |
| name: "category", |
| props: { |
| id: { |
| type: Number, |
| required: true |
| } |
| }, |
| setup(props) { |
| const products = computed(() => |
| fetch("api/v1/categories/" + props.id) |
| .then((data) => data.json()); |
| return { |
| products |
| } |
| } |
| } |
| <template> |
| <div |
| v-for="{id, title, image, price, description} in products" |
| :key="id"> |
| <h1>{{ title }}</h1> |
| <img :src="image" :alt="title"/> |
| <h3> {{ price }} </h3> |
| <p> {{ description }}</p> |
| </div> |
| </template> |
| <script> |
| import { computed } from "vue"; |
| export default { |
| name: "category", |
| props: { |
| id: { |
| type: Number, |
| required: true |
| } |
| }, |
| setup(props) { |
| const products = computed(() => |
| fetch("api/v1/categories/" + props.id) |
| .then((data) => data.json()); |
| return { |
| products |
| } |
| } |
| } |




/src/store/index.js
| import {createLogger, createStore} from 'vuex'; |
| const store = createStore({ |
| plugins: [createLogger()], |
| state: { |
| ... |
| }, |
| mutations: { |
| ... |
| }, |
| actions: { |
| ... |
| }, |
| modules: {} |
| }); |
| export default store; |
| import {createLogger, createStore} from 'vuex'; |
| const store = createStore({ |
| plugins: [createLogger()], |
| state: { |
| ... |
| }, |
| mutations: { |
| ... |
| }, |
| actions: { |
| ... |
| }, |
| modules: {} |
| }); |
| export default store; |
| import {createLogger, createStore} from 'vuex'; |
| const store = createStore({ |
| plugins: [createLogger()], |
| state: { |
| ... |
| }, |
| mutations: { |
| ... |
| }, |
| actions: { |
| ... |
| }, |
| modules: {} |
| }); |
| export default store; |
| import {createLogger, createStore} from 'vuex'; |
| const store = createStore({ |
| plugins: [createLogger()], |
| state: { |
| ... |
| }, |
| mutations: { |
| ... |
| }, |
| actions: { |
| ... |
| }, |
| modules: {} |
| }); |
| export default store; |
/src/store/index.js
| import {createLogger, createStore} from 'vuex'; |
| const store = createStore({ |
| plugins: [createLogger()], |
| state: { |
| products: [], |
| }, |
| mutations: { |
| ... |
| }, |
| actions: { |
| ... |
| }, |
| modules: {} |
| }); |
| export default store; |
| import {createLogger, createStore} from 'vuex'; |
| const store = createStore({ |
| plugins: [createLogger()], |
| state: { |
| products: [], |
| }, |
| mutations: { |
| ... |
| }, |
| actions: { |
| ... |
| }, |
| modules: {} |
| }); |
| export default store; |
/src/store/index.js
| import {createLogger, createStore} from 'vuex'; |
| const store = createStore({ |
| ... |
| mutations: { |
| setProducts: (state, products) => |
| state.products = products; |
| }, |
| actions: { |
| ... |
| }, |
| modules: {} |
| }); |
| export default store; |
| import {createLogger, createStore} from 'vuex'; |
| const store = createStore({ |
| ... |
| mutations: { |
| setProducts: (state, products) => |
| state.products = products; |
| }, |
| actions: { |
| ... |
| }, |
| modules: {} |
| }); |
| export default store; |
/src/store/index.js
| import {createLogger, createStore} from 'vuex'; |
| const store = createStore({ |
| ... |
| }, |
| actions: { |
| getProducts: async (commit, id) => { |
| try { |
| await fetch("/api/v1/categories/" + id) |
| .then((data) => { |
| let products = data.json(); |
| commit("setProducts", products); |
| }); |
| } catch (error) { |
| console.log(error); |
| } |
| } |
| }, |
| modules: {} |
| }); |
| export default store; |
| import {createLogger, createStore} from 'vuex'; |
| const store = createStore({ |
| ... |
| }, |
| actions: { |
| getProducts: async (commit, id) => { |
| try { |
| await fetch("/api/v1/categories/" + id) |
| .then((data) => { |
| let products = data.json(); |
| commit("setProducts", products); |
| }); |
| } catch (error) { |
| console.log(error); |
| } |
| } |
| }, |
| modules: {} |
| }); |
| export default store; |
| import {createLogger, createStore} from 'vuex'; |
| const store = createStore({ |
| ... |
| }, |
| actions: { |
| getProducts: async (commit, id) => { |
| try { |
| await fetch("/api/v1/categories/" + id) |
| .then((data) => { |
| let products = data.json(); |
| commit("setProducts", products); |
| }); |
| } catch (error) { |
| console.log(error); |
| } |
| } |
| }, |
| modules: {} |
| }); |
| export default store; |
| import {createLogger, createStore} from 'vuex'; |
| const store = createStore({ |
| ... |
| }, |
| actions: { |
| getProducts: async (commit, id) => { |
| try { |
| await fetch("/api/v1/categories/" + id) |
| .then((data) => { |
| let products = data.json(); |
| commit("setProducts", products); |
| }); |
| } catch (error) { |
| console.log(error); |
| } |
| } |
| }, |
| modules: {} |
| }); |
| export default store; |
/src/main.js
| import { createApp } from 'vue'; |
| import App from './App.vue'; |
| import router from './router'; |
| import store from './store'; |
| |
| createApp(App).use(store).use(router).mount('#app') |
| import { createApp } from 'vue'; |
| import App from './App.vue'; |
| import router from './router'; |
| import store from './store'; |
| |
| createApp(App).use(store).use(router).mount('#app') |
| import { createApp } from 'vue'; |
| import App from './App.vue'; |
| import router from './router'; |
| import store from './store'; |
| |
| createApp(App).use(store).use(router).mount('#app') |
| import { createApp } from 'vue'; |
| import App from './App.vue'; |
| import router from './router'; |
| import store from './store'; |
| |
| createApp(App).use(store).use(router).mount('#app') |
| import { createApp } from 'vue'; |
| import App from './App.vue'; |
| import router from './router'; |
| import store from './store'; |
| |
| createApp(App).use(store).use(router).mount('#app') |
| import { createApp } from 'vue'; |
| import App from './App.vue'; |
| import router from './router'; |
| import store from './store'; |
| |
| createApp(App).use(store).use(router).mount('#app') |
| import { createApp } from 'vue'; |
| import App from './App.vue'; |
| import router from './router'; |
| import store from './store'; |
| |
| createApp(App).use(store).use(router).mount('#app') |
src/components/category.vue
| <template> |
| <div |
| v-for="{id, title, image, price, description} in products" |
| :key="id"> |
| <h1>{{ title }}</h1> |
| <img :src="image" :alt="title"/> |
| <h3> {{ price }} </h3> |
| <p> {{ description }}</p> |
| </div> |
| </template> |
| <script> |
| import { computed } from "vue"; |
| export default { |
| name: "category", |
| props: { |
| id: { |
| type: Number, |
| required: true |
| } |
| }, |
| setup(props) { |
| const products = computed(() => |
| fetch("api/v1/categories/" + props.id) |
| .then((data) => data.json()); |
| return { |
| products |
| } |
| } |
| } |
| <template> |
| <div |
| v-for="{id, title, image, price, description} in products" |
| :key="id"> |
| <h1>{{ title }}</h1> |
| <img :src="image" :alt="title"/> |
| <h3> {{ price }} </h3> |
| <p> {{ description }}</p> |
| </div> |
| </template> |
| <script> |
| import { computed } from "vue"; |
| export default { |
| name: "category", |
| props: { |
| id: { |
| type: Number, |
| required: true |
| } |
| }, |
| setup(props) { |
| const products = computed(() => |
| fetch("api/v1/categories/" + props.id) |
| .then((data) => data.json()); |
| return { |
| products |
| } |
| } |
| } |
src/components/category.vue
| <template> |
| <div v-for="{ id, title, image, price, description } in products" :key="id"> |
| <h1>{{ title }}</h1> |
| <img :src="image" :alt="title" /> |
| <h3>{{ price }}</h3> |
| <p>{{ description }}</p> |
| </div> |
| </template> |
| |
| <script> |
| import { useStore } from "vuex"; |
| import { computed } from "vue"; |
| export default { |
| name: "Category", |
| props: { |
| id: { |
| type: Number, |
| required: true, |
| }, |
| }, |
| setup(props) { |
| const store = useStore(); |
| let products; |
| |
| store |
| .dispatch("getProducts", props.id) |
| .then(() => (products = computed(() => store.state.products))); |
| return { |
| products, |
| }; |
| }, |
| }; |
| <template> |
| <div v-for="{ id, title, image, price, description } in products" :key="id"> |
| <h1>{{ title }}</h1> |
| <img :src="image" :alt="title" /> |
| <h3>{{ price }}</h3> |
| <p>{{ description }}</p> |
| </div> |
| </template> |
| |
| <script> |
| import { useStore } from "vuex"; |
| import { computed } from "vue"; |
| export default { |
| name: "Category", |
| props: { |
| id: { |
| type: Number, |
| required: true, |
| }, |
| }, |
| setup(props) { |
| const store = useStore(); |
| let products; |
| |
| store |
| .dispatch("getProducts", props.id) |
| .then(() => (products = computed(() => store.state.products))); |
| return { |
| products, |
| }; |
| }, |
| }; |
| <template> |
| <div v-for="{ id, title, image, price, description } in products" :key="id"> |
| <h1>{{ title }}</h1> |
| <img :src="image" :alt="title" /> |
| <h3>{{ price }}</h3> |
| <p>{{ description }}</p> |
| </div> |
| </template> |
| |
| <script> |
| import { useStore } from "vuex"; |
| import { computed } from "vue"; |
| export default { |
| name: "Category", |
| props: { |
| id: { |
| type: Number, |
| required: true, |
| }, |
| }, |
| setup(props) { |
| const store = useStore(); |
| let products; |
| |
| store |
| .dispatch("getProducts", props.id) |
| .then(() => (products = computed(() => store.state.products))); |
| return { |
| products, |
| }; |
| }, |
| }; |