首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Vue.js组件在页面上没有可视化显示。

Vue.js组件在页面上没有可视化显示。
EN

Stack Overflow用户
提问于 2020-11-18 20:30:07
回答 1查看 165关注 0票数 2

我有以下名为TeamCard的Vue组件:

代码语言:javascript
复制
<template>
    <div class="m-8 max-w-sm rounded overflow-hidden shadow-lg">
        <!-- removed fro brevety -->
        div class="text-gray-900 font-bold text-xl mb-2">{{ name }}</div>
            <p class="text-gray-700 text-base"> {{ description }} </p>
            <!-- removed fro brevety -->
        </div>
    </div>
</template>
<script>
    export default {
        name: "TeamCard",
        props: {
            name: {
                type: String,
                required: true,
            },
            description: {
                type: String,
                required: true,
            },
        }
    };
</script>

<style scoped>
    @import "https://unpkg.com/tailwindcss@^2/dist/tailwind.min.css";
</style>

我以以下方式在HTML页面(Spring模板)中调用该组件:

代码语言:javascript
复制
<teamCard v-bind:name="'Hawks'" v-bind:description="'Best team'" ></teamCard>
<script src="https://unpkg.com/vue"></script>
<script th:src="@{/TeamCard/TeamCard.umd.min.js}"></script>
<script>
    (function() {
        new Vue({
            components: {
                teamCard: TeamCard
            }
        })
    })();
</script>

当我转到具有第二个片段的浏览器中的页面时,没有显示任何内容。控制台中没有错误。我做错了什么?如何显示组件?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-11-18 21:26:03

我从来没有见过Vue这样使用,但它似乎没有安装元素的应用程序。试试这个:

代码语言:javascript
复制
<div id="app">
   <team-card v-bind:name="'Hawks'" v-bind:description="'Best team'"></team-card>
</div>

代码语言:javascript
复制
(function() {
  new Vue({
    el: '#app',
    components: {
      teamCard: TeamCard
    }
  })
})();
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64900892

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档