V
V
Vladimir Golub2021-05-26 13:03:04
Vue.js
Vladimir Golub, 2021-05-26 13:03:04

How to add a non-global mixin to nuxt?

Create a mixin

export default {
  computed: {
   last: function () {
      return [ ...this.items ].reverse().slice(0, 5)
    },
   old: function () {
      return [ ...this.items ].reverse().slice(5)
    }
  },
  data: function () {
    return {
      items: [
        {
          id: 18,
        },
        {
          id: 17,
        },
        {
          id: 1,
        },
        ...


I add it not a page
import awardsMixin from '@/plugins/mixins/non-global/items';

  export default {
    name: "AwardsSection",
    mixin: [awardsMixin],
    mounted() {
      console.log(this.last) 
    }


I get undefined, what am I doing wrong?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Kuznetsov, 2021-05-26
@RazerVG

Not mixin, but mixin s , I guess.

A
Alexey Yarkov, 2021-05-26
@yarkov Vue.js

Import itemsMixin and include awardsMixin . So intended?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question