【问题标题】:Vue Component does not render...Renders as empty HTML commentVue 组件不呈现...呈现为空 HTML 注释
【发布时间】:2018-10-21 05:28:06
【问题描述】:

问题:

  • Vue 组件在屏幕上呈现为<!---->

设置:

  • 应用程序在 C# Core 2.0 中
  • Vue 版本 2.5.16
  • 使用gulp复制静态js文件到/wwwroot
    gulp.src('./node_modules/vue/dist/vue.min.js') .pipe(gulp.dest('./wwwroot/dist/'))
  • 调用以在 HTML 中加载 Vue
    <script src="~/dist/vue.min.js" asp-append-version="true"></script>
  • 我有四个组件。两个使用字符串文字模板,两个使用<template>。在后者中,只有一个显示。
    <template id="paging-template"></template> <template id="modal-template"></template>

    Vue.component('modal',{ template:'#modal-template'}); Vue.component('paging',{ template:'#paging-template'});

Modal 使用 &lt;modal&gt;&lt;/modal&gt; 调用,Paging 使用 &lt;paging&gt;&lt;/paging&gt;

模态显示正确。分页显示为&lt;!----&gt;,但使用 Chrome 中的 Vue 调试器插件,我可以看到模型和分页组件的所有内容。

我错过了什么?

编辑: JSFiddle Link

这个 css 不是我的,只是他们提供的 Vue 模板上的默认值

【问题讨论】:

  • 能否显示 index.html 和 application.vue 或 vue 主页面的语法。
  • 您没有提供足够的信息让我们确定问题所在。
  • 我没有任何 .vue 文件。我的 Vue 模型在加载到页面的常规 .js 文件中实例化。如果没有提供足够的信息,您能否具体说明您要查找的信息?
  • 提供的 JSFiddle 链接

标签: c# vue.js vue-component asp.net-core-2.0


【解决方案1】:

您的示例有很多问题(所有这些都在浏览器的控制台选项卡中可见):

您的类绑定语法不正确。您尝试绑定类的所有实例如下:

v-bind:class="'disabled': previousDisabled"

应更新为:

v-bind:class="{disabled: previousDisabled}"

isNumber 不是一种方法。可以换成!Number.isNaN(

更新JSFiddle

【讨论】:

  • 我的英雄...我花了这么多时间盯着代码看,以至于对这些明显的错误视而不见。遗憾的是我的控制台没有显示任何错误。
猜你喜欢
  • 2019-06-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-11-14
  • 2019-08-15
  • 2017-06-26
  • 1970-01-01
  • 2017-02-22
相关资源
最近更新 更多