K
K
Konstantin Malyarov2018-07-06 11:58:07
Vue.js
Konstantin Malyarov, 2018-07-06 11:58:07

Why is the component not working in VueJS?

<!DOCTYPE html>
<html lang="en">
<head>
    <title>Консультация</title>
    {% load staticfiles %}
    <script src="{% static 'vue/vue.min.js' %}"></script>
    <script src="{% static 'axios/axios.min.js' %}"></script>
    <style type="text/css">
        * {
            margin: 0;
            padding: 0;
        }
        p {
            padding: 10px;
        }
        .left {
            position: absolute;
            left: 0;
            top: 0;
            width: 35%;
        }
        .right {
            position: absolute;
            right: 0;
            top: 0;
            width: 65%;
        }
    </style>
</head>

<body id="consultation">
<div class="left">
    <consultation :patient_id="{{ patient.id }}"></consultation>
</div>
<div class="right">
    Текст
</div>
</body>
<script src="{% static 'patient/consultation.js' %}"></script>
</html>

One root element.
Vue.component('consultation', {
    data() {
        return {
            patient: null
        }
    },
    prop: ['patient_id'],
    template: '<div>TEST</div>',
    beforeCreate() {
        console.log('test')
    }
})

new Vue({
    el: '#consultation',
})

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir Proskurin, 2018-07-06
@Konstantin18ko

Vue app can't be placed on body, make separate div

E
Evgeny Kulakov, 2018-07-06
@kulakoff Vue.js

Little data, but here it is: it :patient_id="{{ patient.id }}"should look like this::patient_id="patient.id"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question