我试图利用另一个具有预定义属性的组件中的主组件.

以下是我试图实现的目标,但结果是我得到了一个空的div.

<template>
    <call-dialog-link
        :id="id"
        :url=url"
        message="Are you sure you wish to remove this record?"
        label="Remove"
        css-classes="alert"
    ></call-dialog-link>
</template>
<script>
    import CallDialogLink from './CallDialogLink.vue';
    export default {
        props: {
            id: {
                type: String,
                required: true
            },
            url: {
                type: String,
                required: true
            }
        },
        components: {
            'call-dialog-link': CallDialogLink
        }
    };
</script>

这是CallDialogLink

<template>
    <span class="clickAble" :class="cssClasses" v-text="label" @click="clicked()"></span>
</template>
<script>
    export default {
        props: {
            id: {
                type: String,
                required: true
            },
            url: {
                type: String,
                required: true
            },
            message: {
                type: String,
                required: true
            },
            label: {
                type: String,
                required: true
            },
            cssClasses: {
                type: String,
                required: false
            }
        },
        mounted() {
            window.EventHandler.listen('remove-dialog-' + this.id + '-called', (data) => {
                window.location.reload(true);
            });
        },
        methods: {
            clicked() {
                window.EventHandler.fire('top-confirm', {
                    id: 'remove-dialog-' + this.id,
                    message: this.message,
                    url: this.url
                });
            }
        }
    };
</script>

知道我做错了什么吗?

推荐答案

我相信你的代码有错.

<template>
    <call-dialog-link
        :id="id"
        :url="url" // didn't open the double quote here
        message="Are you sure you wish to remove this record?"
        label="Remove"
        css-classes="alert"
    ></call-dialog-link>
</template>

Vue.js相关问答推荐

如何在 vue js 的一页路由下显示不同的 category._id

在Vue cli项目中,Laravel api app放在哪里以及如何在vue js中调用api?

在组件之间共享 websocket 连接

nuxt.js - 预加载 .woff 字体加载为@font-face

我可以从手表调用方法并安装吗?

如何将对象作为props传递并让组件更新子对象

一个 div 组件中的 Vue.js 2.0 路由链接

在 v-for 的情况下如何从 v-model 输入更新 Vuex 存储

未捕获的类型错误:c.querySelectorAll 不是函数

删除一行后刷新 Bootstrap-Vue 表

基本 vue.js 2 和 vue-resource http 获取变量赋值

Vuejs css 范围性能

Vue在按钮单击时添加一个组件

使用 Spring Boot(VueJS 和 Axios 前端)禁止发布 403 帖子

VueJS 2 在多个组件上debounce

更改事件上的 Select2 在 Vuejs 中不起作用

在 Vuex 模块中进行继承的方法

在鼠标悬停时动态添加和删除类

vue-cli@3 没有可用于依赖类型的模块工厂:CssDependency

隐藏特定标题及其在 vuetify 数据表中的对应列