javascript - Why is my VueJs component not showing in the frontend? - Stack Overflow

I am trying to implement vuejs in a current django project.It kind of worked. However I wanted a clean

I am trying to implement vuejs in a current django project. It kind of worked. However I wanted a cleaner structure and use vuejs ponents.

However the ponents are not showing up in the frontend.

So here I have my basic vue ponent (from the vueify-laravel example)

<template>
    <div>
        <h1>Hello, {{ name }}</h1>
        <input type="text" v-model="name">
    </div>
</template>

<script>
    export default {
        data: function() {
            return {
                name: 'Laracasts'
            };
        }
    };
</script>

<style>
    h1 {
        color: red;
    }
</style>

In my app.js I have

var Vue = require('vue')
import Greeter from './ponents/Greeter.vue'

new Vue({
    el: '#app',

    ponents: {
        greeter: Greeter
    }
});

And finally in one of my django templates

<div id="app">
    <greeter></greeter>
</div>

I have vue dev tools installed, and it shows me the root node and then the greeter node. But nothing in it. And the app container is empty too.

I am trying to implement vuejs in a current django project. It kind of worked. However I wanted a cleaner structure and use vuejs ponents.

However the ponents are not showing up in the frontend.

So here I have my basic vue ponent (from the vueify-laravel example)

<template>
    <div>
        <h1>Hello, {{ name }}</h1>
        <input type="text" v-model="name">
    </div>
</template>

<script>
    export default {
        data: function() {
            return {
                name: 'Laracasts'
            };
        }
    };
</script>

<style>
    h1 {
        color: red;
    }
</style>

In my app.js I have

var Vue = require('vue')
import Greeter from './ponents/Greeter.vue'

new Vue({
    el: '#app',

    ponents: {
        greeter: Greeter
    }
});

And finally in one of my django templates

<div id="app">
    <greeter></greeter>
</div>

I have vue dev tools installed, and it shows me the root node and then the greeter node. But nothing in it. And the app container is empty too.

Share Improve this question asked Nov 29, 2015 at 14:41 Jakub JuszczakJakub Juszczak 7,9174 gold badges22 silver badges41 bronze badges 1
  • 1 The code seems to be ok. Please, check your browserify options. – pespantelis Commented Nov 29, 2015 at 16:43
Add a ment  | 

1 Answer 1

Reset to default 11

If the template is ing from django then you have to escape the {{ and }}. To turn off the template parsing use {% verbatim %} or you can also use {% templatetag openvariable %} (and then closevariable).

try:

{% verbatim %}
<template>
    <div>
        <h1>Hello, {{ name }}</h1>
        <input type="text" v-model="name">
    </div>
</template>
{% endverbatim %}

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1743950551a4534866.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信