D
D
Daniil Postnov2019-07-19 13:21:03
Vue.js
Daniil Postnov, 2019-07-19 13:21:03

How to fix bug with vue component?

There are 2 components: PromocodesTable, PromocodesItem. Both single file vue components.
An error pops up: "Unknown custom element: "
Code PromocodesItem

<template>
  <tr class="table-row">
      <td class="table-col">
          <span>9</span>
      </td>
      <td class="table-col">
          <span>Вконтакте</span>
      </td>
      <td class="table-col">
          <span>10%</span>
      </td>
      <td class="table-col">
          <span
              :class="{ 'text-green': width <= 767 }"
          >
              {{ width <= 767 ? 'Активен' : 'Да'}}
          </span>
      </td>
  </tr>
</template>

<script>
export default {
  name: 'PromocodesItem'
}
</script>

Code PromocodesTable:
<template>
    <div class="promocodes-component">
        <table class="table finances-table promocodes-table">
            <thead
                v-if="width > 767"
                class="table-head"
            >
                <tr class="table-row">
                    <td class="table-col" style="width: 10%">
                        <span class="text-semi">ID</span>
                    </td>
                    <td class="table-col" style="width: 30%">
                        <span class="text-semi">Промокод</span>
                    </td>
                    <td class="table-col" style="width: 30%">
                        <span class="text-semi">Величина</span>
                    </td>
                    <td class="table-col" style="width: 30%">
                        <span class="text-semi">Активность</span>
                    </td>
                </tr>
                <tr height="20"></tr>
            </thead>
            <tbody class="table-body finances-table-body">
                <PromocodesItem></PromocodesItem>
            </tbody>
        </table>
    </div>
</template>

<script>
import { mapGetters } from 'vuex';
import { PromocodesItem } from './PromocodesItem.vue';

export default {
    name: 'PromocodesTable',
    computed: {
        ...mapGetters({
            width: 'ui/width'
        })
    },
    components: {PromocodesItem}
}
</script>

Question. Why is the import not working? When mount in promocodesTable variable PromocodesItem == undefined
Both components are on the same level.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Michael, 2019-07-19
@postnov_daniil

import PromocodesItem from "./PromocodesItem.vue";

A
Andrey Suha, 2019-07-19
@andreysuha

<promocodes-item></promocodes-item>write like this in template

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question