Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
LongTengDao opened this issue Dec 9, 2017 · 1 comment

Comments

@LongTengDao
Copy link

LongTengDao commented Dec 9, 2017

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.
所以我想,这应该是一个引擎升级的疏忽,而非有意为止。

@yyx990803
Copy link
Member

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

lovelope pushed a commit to lovelope/vue that referenced this issue Feb 1, 2018
f2009 pushed a commit to f2009/vue that referenced this issue Jan 25, 2019
aJean pushed a commit to aJean/vue that referenced this issue Aug 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants