Vue: global namespaced component name cause a warn. 全局含命名空间的组件名会报警告。

Created on 9 Dec 2017  ·  1Comment  ·  Source: vuejs/vue

Version 版本

2.5.9

Reproduction link 重现链接

https://jsfiddle.net/50wL7mdz/82050/#unnecessary-sample-but-required#不必要的必填示例

Steps to reproduce 重现步骤

Vue.component('my:component',{ template:'<br />' });

What is expected? 期望的结果是什么?

Don't cause a warn.
不要触发警告。

What is actually happening? 实际的结果是什么?

[Vue warn]: Invalid component name: "my:component". Component names can only contain alphanumeric characters and the hyphen, and must start with a letter.

warn @ vue:580

Vue.extend @ vue:4675

Vue.(anonymous function) @ vue:4772

install @ 0:896

Vue.use @ vue:4631


In component context, it will not cause a warn:
在局部组件中,这不会引发警告:

new Vue({

    template:'<my:component />',

    components:{

        'my:component':{ template:'<br />' }

    }

});

And, in global context, the namespaced component is usable, although it cause a warn.
另外,在全局组件中,虽然会引发警告,但组件依然可以正常使用。

So I think, this might be a problem from carelessness while engine upgrading, not intentional.
所以我想,这应该是一个引擎升级的疏忽,而非有意为止。

Most helpful comment

这个限制是有意的,因为 : 通常用来标示 XML 级别的 namespace,在 HTML 的用例中尽量避免。

>All comments

这个限制是有意的,因为 : 通常用来标示 XML 级别的 namespace,在 HTML 的用例中尽量避免。

Was this page helpful?
0 / 5 - 0 ratings

Related issues

smolinari picture smolinari  ·  116Comments

ShuvoHabib picture ShuvoHabib  ·  40Comments

cherry-geqi picture cherry-geqi  ·  35Comments

wenLiangcan picture wenLiangcan  ·  39Comments

karevn picture karevn  ·  42Comments