【问题标题】:How to prevent Vue to interpreted custom tags?如何防止 Vue 解释自定义标签?
【发布时间】:2016-01-15 11:37:17
【问题描述】:

我有 Vue 应用程序。但是我需要添加一些自定义标签,这些标签来自另一个 JS 框架。如何防止 Vue 尝试解释它?

<slider floor="100" ceiling="1000" step="1" ></slider>

现在我收到错误: Unknown custom element: &lt;slider&gt; - did you register the component correctly?

【问题讨论】:

  • 要获得提交的可能答案,在您的应用中包含相关代码会有所帮助。您在哪里导入/注册组件?

标签: vue.js


【解决方案1】:

如果您使用的是 Vue 2.0 版

你可以使用配置的ignoreElements

Vue.config.ignoredElements = ['slider']

已经在 Vue 2.0 中实现,将在 Vue 1.1 中实现

资源:vuejs issues 3090: Ignore some custom HTML components

【讨论】:

    【解决方案2】:

    这是一个警告,而不是错误,所以你应该没有问题。您可以使用Vue.config.silent = true 隐藏所有警告。另外我认为如果您设置Vue.config.debug = false,它将被隐藏。所以它实际上只是开发过程中的一个记录警告,但不应该影响生产。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-03-24
      • 2022-07-01
      • 2018-02-17
      • 1970-01-01
      • 1970-01-01
      • 2017-05-18
      • 1970-01-01
      • 2018-02-05
      相关资源
      最近更新 更多