最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin2浏览0评论

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 %}
发布评论

评论列表(0)

  1. 暂无评论