C
C
coderisimo2019-06-27 21:05:29
JavaScript
coderisimo, 2019-06-27 21:05:29

Why does the "Property or method "item_" is not defined" error in a component occur in one of two places of use?

Attention, mystic! The component is used in two places. The dropdown list is rendered:

<select  class="form-control form-control-sm client-file"
                v-model="attachedFileType" id="file_type"
                name="file_type">
                     <option v-for="(item, index) in filesTypes" :value="item.id">
                           {{item.item_title}}
                    </option>
   </select>

and error :

[Vue warn]: Property or method "item" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property.

the filesTypes array from which item is taken has:
Vue.component('pdf-viewer-dialog', {
        props: ['file', 'clientId'],
        data: function () {
            return {
                componentHeight: '',
                modalId: '',
                pdfId: '',
                email_email: '',
                email_subject: '',
                email_text: '',
                attachedFileType: '',
                attachedFileDescription: '',
                filesTypes: <?= CommonHelper::getArrayArraysAsJsArray(\app\models\ClientFile::getTypes()); ?>
            }
        },

It would be nice if there was a mistake all the time, but no. On the test page (there is a simple application for testing) everything is ok, but on the real one (there is a lot of logic) it crashes. Tell me, what are the pitfalls here? How can a main application "spoil" a component? Where to dig? In the console there is a link to the very beginning, which, of course, is VERY informative.
5d15055f685f5294300111.jpeg
Thanks

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
coderisimo, 2019-07-05
@coderisimo

The solution, maybe someone will come in handy,
try using instead:
here is a template connection:
I mean exactly the syntax with slash quotes.
this is not very convenient, because the IDE does not work adequately with such HTML. But, you can use php variable:

template: `<?= $template ?>` 
//  $template получаю  ob_get_clean() , зато все на одной странице и html  полноценно форматируется и редактируется IDE

or just not use crutches, but collect everything with assemblers.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question